471,893 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,893 software developers and data experts.

Putting form values in array

132 100+

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];
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;
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
1 1163
608 512MB
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 );

Here Ele1 is the id given to your text box

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

Do like this surely your code will work;

Ramanan Kalirajan
Jul 28 '08 #2

Post your reply

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

Similar topics

5 posts views Thread by Yang Li Ke | last post: by
9 posts views Thread by Ken | last post: by
4 posts views Thread by Cerebral Believer | last post: by
26 posts views Thread by Jerim79 | last post: by
1 post views Thread by Muchach | last post: by
2 posts views Thread by Phil Latio | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.