Okay, I have an awesome book on javascript. It goes very in-depth in arrays, but can't answer one simple question:
Can you later add more variables to an array, without rewriting the whole thing?
I have 10 variables for storing data. I want to store the empty ones inside another variable using an array. My code looks like this:
I begin the code by declaring each variable, then storing them each inside another variable using the "Array()" attribute.
Now, as I slowly begin to use and empty these variables (store1,store2,...store10), I want to obviously remove each from the list as it's filled. Then as I empty them, I want to add them back to the array again.
I can't do either of these things. I'm not new to javascript, but I'm slightly new to arrays in general. I can obviously refer back to the variables/value stored inside the arrays:
This wouldn't do much, returning some empty values, but you get my point.
HELP!!!
Last edited by bladesage on Tue May 23, 2006 10:52 pm; edited 1 time in total
Can you later add more variables to an array, without rewriting the whole thing?
I have 10 variables for storing data. I want to store the empty ones inside another variable using an array. My code looks like this:
| Code: |
| <script type="text/javascript" language="javascript">
var store1; var store2; var store3; var store4; var store5; var store6; var store7; var store8; var store9; var store10; var empties = new Array(store1,store2,store3,store4,store5,store6,store7,store8,store9,store10); </script> |
I begin the code by declaring each variable, then storing them each inside another variable using the "Array()" attribute.
Now, as I slowly begin to use and empty these variables (store1,store2,...store10), I want to obviously remove each from the list as it's filled. Then as I empty them, I want to add them back to the array again.
I can't do either of these things. I'm not new to javascript, but I'm slightly new to arrays in general. I can obviously refer back to the variables/value stored inside the arrays:
| Code: |
|
<script type="text/javascript" language="javascript"> function restorevals() { document.getElementById("outbox1").value = empties[2]; document.getElementById("outbox2").value = empties[0]; } </script> |
This wouldn't do much, returning some empty values, but you get my point.
HELP!!!
Last edited by bladesage on Tue May 23, 2006 10:52 pm; edited 1 time in total
