By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,829 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

Putting form values in array

100+
P: 132
Hi,

In one of my scripts I'm having difficulties adding fromvalues to an array.

For testing purposes I made an array like this:
Expand|Select|Wrap|Line Numbers
  1. var mijnlotto1 = [19,23,27,32,34,41];
  2.  
This way my script works.
However I want to fill in the array dynamically. So I want to create the array called mijnlotto1 from input boxes that are on my page. So I did:
Expand|Select|Wrap|Line Numbers
  1. var mijnlotto1 = new Array();
  2. mijnlotto1[0]=document.combinatie1.nr1.value;
  3. mijnlotto1[1]=document.combinatie1.nr2.value;
  4. mijnlotto1[2]=document.combinatie1.nr3.value;
  5. mijnlotto1[3]=document.combinatie1.nr4.value;
  6. mijnlotto1[4]=document.combinatie1.nr5.value;
  7. mijnlotto1[5]=document.combinatie1.nr6.value;
  8.  
where combinatie1 is the name of the form and nr1 to nr6 are the names of the input boxes. However using this method the script won't work.

The array mijnlotto1 is being used to compare to another array. So I'm guessing the format of mijnlotto1 is not correct. However I'm not sure what the right format would be.

The other array is fixed and is created like this:
Expand|Select|Wrap|Line Numbers
  1. lotto[0] = new lottohistory('4-2-1978', '6', '17', '30', '31', '35', '37', '15', '460171.2', '0', '0', '18', '1701', '35206', '1.24');
Any help would be appreciated.
Jul 28 '08 #1
Share this Question
Share on Google+
1 Reply


RamananKalirajan
100+
P: 607
Hi dude, dont do that in that way rather do like this

[HTML]<script language="javascript">
var myArray=[];
function assign()
{
myArray.push(document.getElementById('Ele1').value );
}
</script>[/HTML]

Here Ele1 is the id given to your text box

Ex. <input type="text" id="Ele1">

Do like this surely your code will work;

Regards
Ramanan Kalirajan
Jul 28 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.