set php variable on radio box without submitting the form
i have a set of radio boxes, and a select list. The radio boxes represents the objects, and the select list represents the number of pieces for ever开发者_JAVA技巧y object (to be bought). i want to synchronise the stock with the select list. meaning that, if i choose the first product and i have only 6 products in the stock, i want the maximum value in the select list to be 6. if i choose the second and i have only 2 products in the stock, i want the maximum to be 2.
How do i synchronise the select list with the radio boxes?
thanks!
As PHP is a dependent server-side script, this would be very hard to do, if not impossible with just PHP. I see two options:
Use a bit of Javascript to refresh the page whenever a form element is updated, and use those corresponding values in a PHP script to update the form with the new values.
Use JQuery or AJAX to request a PHP script that will do the same thing. Same in concept, but wont refresh the page each time.
You need to write javascript that loads with the page, that will limit the amounts for those fields. The javascript would be created in your php and inserted into the page on load.
精彩评论