i have this piece of code i would like to validate using javascript. I have the validation code already , all i would like to know is how do you send a changeable variable to javascript i.e
while($row1 = mysql_fetch_array($result)){
$sel = ($row1['productid'] == $row['productid']) ? "selected=\"selected\"" : "";
printf("<option value=\"%s\" %s>%s</option>\n", $row1['productid'], $sel, $row1['product']);
}
echo "</select></td>";
//resets counter to 0 on products list
mysql_data_seek($result,0);
//print " ";
print"<td><input style=\"text-align:center\" type=text name=productitemsupdate_$num value=\"$row[productitems]\" size=5 id=productitemsupdate_$num></td>";
// print " ";
print"<td><input style=\"text-align:center\" type=text name=productcostupdate_$num value=\"$row[productcost]\" size=5 ></td>";
$pay= $row[productitems] * $row[productcost];
$id2=$num;
The above code is part of a while loop. you will notice i have an id fields in the productsitems input. at the end to make it different from the other productsitems i have added a _$num at the end.
It is this num i would like to pass to javascript so it knows which line it is working on .
function validate(form) {
var phoneno = form.phoneno.value;
var deldate = form.deldate.value;
var name = form.name.value;
var extracharge = form.extracharge.value;
var productsitems = form.productitems_$num.value; <---- this line here i need help with
so in theory i need to validate if product items in all input boxes are integer.
i have the integer part i just know how to tell javascript which line it is working on.
kardklub