...

View Full Version : validating an array field



Harman
07-16-2004, 11:00 PM
Hi!
i have a form which is which has an array field
php code***********
while($row = mysql_fetch_object(...){
$tbl .= '<input name="qty['.$x.']" type="text" size="4" maxlength="4"/>';
...
}


when i try to do something like this, it doesnt like it :rolleyes:
javascript code ***************
for(i=0;i<total_rows; i++){
...
frm_name.qty[i].value
...
}

I would like to validate it on submit to check at least one of then has a value and and that the values entered are numeric...thanks

jamescover
07-17-2004, 03:03 AM
Hi!
i have a form which is which has an array field
php code***********
while($row = mysql_fetch_object(...){
$tbl .= '<input name="qty['.$x.']" type="text" size="4" maxlength="4"/>';
...
}


when i try to do something like this, it doesnt like it :rolleyes:
javascript code ***************
for(i=0;i<total_rows; i++){
...
frm_name.qty[i].value
...
}

I would like to validate it on submit to check at least one of then has a value and and that the values entered are numeric...thanks


Can you post your entire form...?



-james

glenngv
07-19-2004, 11:22 AM
Hi!
i have a form which is which has an array field
php code***********
while($row = mysql_fetch_object(...){
$tbl .= '<input name="qty['.$x.']" type="text" size="4" maxlength="4"/>';
...
}


when i try to do something like this, it doesnt like it :rolleyes:
javascript code ***************
for(i=0;i<total_rows; i++){
...
frm_name.qty[i].value
...
}

I would like to validate it on submit to check at least one of then has a value and and that the values entered are numeric...thanks

var val = frm_name.elements['qty['+i+']'].value;
alert(val);

Here's more info on bracket notation (http://www.litotes.demon.co.uk/js_info/sq_brks2.html)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum