L
libsfan01
Hi all whats wrong with this script?
i have named a form text box dynamically using php each row has a
textbox called q101, q102 ... etc and i want to make sure my users dont
input a quantity greater than the value of that box. to know which box
applies to which of the products i have used a radio button which
contains the id of the product which corresponds to the name of the box
when a q is added to the front (javascript seems not to like forn names
that are just numbers).
what im trying to do is get the user to click the radio button submit
the form and have the id of the radio button passed as a variable along
with the letter q to the javascript function which uses this string to
locate the right quantity text box to tell the user if he has selected
too many of the product in question.
javascript seems to have a problem in taking the value of a text box
adding it to a string and using this new combined string value to
reference the name of another form element and check its value.
when i use a constant e.g. q191 instead of the var quantityvariation
(in maxquantity declaration) it works fine, maxquantity is the value of
the textbox that contains the value for quantity.
Any idea how i can get this to work?
<script language="javascript" type="text/javascript">
function validForm(product) {
var variationid = product.order.value;
var quantityvariation = "q" + variationid;
var maxquantity = product.quantityvariation.value;
//0 < 1 is just there for testing
if (0 < 1) {
alert(maxquantity)
product.quantity.focus()
return false
}
}
</script>
i have named a form text box dynamically using php each row has a
textbox called q101, q102 ... etc and i want to make sure my users dont
input a quantity greater than the value of that box. to know which box
applies to which of the products i have used a radio button which
contains the id of the product which corresponds to the name of the box
when a q is added to the front (javascript seems not to like forn names
that are just numbers).
what im trying to do is get the user to click the radio button submit
the form and have the id of the radio button passed as a variable along
with the letter q to the javascript function which uses this string to
locate the right quantity text box to tell the user if he has selected
too many of the product in question.
javascript seems to have a problem in taking the value of a text box
adding it to a string and using this new combined string value to
reference the name of another form element and check its value.
when i use a constant e.g. q191 instead of the var quantityvariation
(in maxquantity declaration) it works fine, maxquantity is the value of
the textbox that contains the value for quantity.
Any idea how i can get this to work?
<script language="javascript" type="text/javascript">
function validForm(product) {
var variationid = product.order.value;
var quantityvariation = "q" + variationid;
var maxquantity = product.quantityvariation.value;
//0 < 1 is just there for testing
if (0 < 1) {
alert(maxquantity)
product.quantity.focus()
return false
}
}
</script>