Add 1 to the value of a textbox which is with a PHP loop
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Friday, April 9, 2010 10:05 AM

I'm having some trouble getting this to work fully, I've got it part way but I am now a little stuck. Basically I have a textbox with a button on one side which adds 1 to the value of the textbox. This work ok, except that the ID element I'm referencing in the javascript is part of a loop, so it only applies the change to the first part of the loop. I'm thinking I need to use a different ID for each textbox (as it's produced by the loop), but have no idea how to reference it in the javascript after that. Here is my code: function count_add(){ var elem = parseInt(document.getElementById("ride_add").value) if (!isNaN(elem)) { document.getElementById("ride_add").value = (elem +1) } else { document.getElementById("ride_add")   More>>

I'm having some trouble getting this to work fully, I've got it part way but I am now a little stuck.

Basically I have a textbox with a button on one side which adds 1 to the value of the textbox. This work ok, except that the ID element I'm referencing in the javascript is part of a loop, so it only applies the change to the first part of the loop. I'm thinking I need to use a different ID for each textbox (as it's produced by the loop), but have no idea how to reference it in the javascript after that. Here is my code:

			



while($row_ride = mysql_fetch_array( $result_ride ))
{
echo $row_ride['ride_name'];
echo " ";
echo " ";
echo " ";
echo "
";
}


Can anyone help?    <<Less
About | Sitemap | Contact