javascripts help
-
I need to create more than one text box with the same name(this call array),with the code; for i = 1 to CInt(request.Form("quantity")) count = count + 1 serial_field = "serial"&count end loop then, when I need to check whether user already fill in this text box, I can not access that text box name.Text box name suppose to be serial1, serial2 and so on.I am using this code; for (a=o;a<=30;a++){ if (document.Reg.element.serial[a].value == "") { err = true; msgstring = "Fill in serial number"; } } I can access the value only if I directly use the name like; if (document.Reg.element.serial1.value == "") { err = true; msgstring = "Fill in serial number"; } Any suggestion what I should do to solve this problem. I am sorry my explanation is quite massy. Thanks
-
I need to create more than one text box with the same name(this call array),with the code; for i = 1 to CInt(request.Form("quantity")) count = count + 1 serial_field = "serial"&count end loop then, when I need to check whether user already fill in this text box, I can not access that text box name.Text box name suppose to be serial1, serial2 and so on.I am using this code; for (a=o;a<=30;a++){ if (document.Reg.element.serial[a].value == "") { err = true; msgstring = "Fill in serial number"; } } I can access the value only if I directly use the name like; if (document.Reg.element.serial1.value == "") { err = true; msgstring = "Fill in serial number"; } Any suggestion what I should do to solve this problem. I am sorry my explanation is quite massy. Thanks
serial_field = "serial"&count
gives all the fields different names - serial1, serial2 etc... Just useserial_field = "serial";
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
serial_field = "serial"&count
gives all the fields different names - serial1, serial2 etc... Just useserial_field = "serial";
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
Ya, that true according to logic but the problem bow, the object(text box) has been created first than we need to check when user click on save button. How we can refer to the object name?
I'm not a javascript expert, but you should be able to use
document.all.serial[0].value
document.all.serial[1].value
etc...Hope this helps,
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
I'm not a javascript expert, but you should be able to use
document.all.serial[0].value
document.all.serial[1].value
etc...Hope this helps,
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
I need to create more than one text box with the same name(this call array),with the code; for i = 1 to CInt(request.Form("quantity")) count = count + 1 serial_field = "serial"&count end loop then, when I need to check whether user already fill in this text box, I can not access that text box name.Text box name suppose to be serial1, serial2 and so on.I am using this code; for (a=o;a<=30;a++){ if (document.Reg.element.serial[a].value == "") { err = true; msgstring = "Fill in serial number"; } } I can access the value only if I directly use the name like; if (document.Reg.element.serial1.value == "") { err = true; msgstring = "Fill in serial number"; } Any suggestion what I should do to solve this problem. I am sorry my explanation is quite massy. Thanks
Try this: (Note: Change the 6 in the first "for loop" with your total number of textboxes.) function fnCheck() { var strTextBoxName; for(var i=1;i<6;i++) { strTextBoxName = "serial" + i; for(var j=0;j
-
I'm not a javascript expert, but you should be able to use
document.all.serial[0].value
document.all.serial[1].value
etc...Hope this helps,
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
This would work if the fields all have the same name (serial in this example). But here the fields include an increasing number so he needs to use:
for(var i = x; i < y; i++) { document.formName["serial" + i]; }
where x is the number of the first field and y is the number of the last. -
This would work if the fields all have the same name (serial in this example). But here the fields include an increasing number so he needs to use:
for(var i = x; i < y; i++) { document.formName["serial" + i]; }
where x is the number of the first field and y is the number of the last.Yeah I know, hence my first reply :)
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
Try this: (Note: Change the 6 in the first "for loop" with your total number of textboxes.) function fnCheck() { var strTextBoxName; for(var i=1;i<6;i++) { strTextBoxName = "serial" + i; for(var j=0;j