|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
unchecking pre-checked html checkboxes to amend a selection list
I have a script which generates a "selections" web page, where visitors click checkboxes and their selections are written to a database. They can view their selections by calling the page and current selections are shown as pre-checked by making the variable $checked = "checked", as in...
<input type="checkbox" name="C1" value="Y" $checked> (For items not previously selected, $checked = "", so they are not pre-checked) If visitors de-select a current selection by unchecking that checkbox, the existing "checked" value is not changed, so when checked boxes are collected by the script, all existing selections remain selected although onscreen they are de-selected. Can anyone suggest a way around this? |
|
#2
|
|||
|
|||
|
Do you want the changes to be applied?
|
|
#3
|
|||
|
|||
|
I want it so that a newly-checked box is accepted as a check (that bit works) and that a box which they click to uncheck it is identified as an unchecked box when the variables are passed to perl.
Is that what you were asking me for? |
|
#4
|
|||
|
|||
|
Two parts to a checkbox
Try this sample code:
<html> <head> <title>Test Page</title> <script language="javascript"> function see() { var d=document.forms[0]; alert(d.C1.checked); alert(d.C1.value); alert(d.C2.checked); alert(d.C2.value); alert(d.C3.checked); alert(d.C3.value); } </script> </head> <body bgcolor="#FFFFFF"> <form method="POST"> <p><input type="checkbox" checked name="C1" value="one"></p> <p><input type="checkbox" name="C2" value="two"></p> <p><input type="checkbox" name="C3" value="three"></p> <p><input type="button" name="B1" onClick="see()" value="Submit"></p> </form> </body> </html> Note: the value remains but the checked is true / false. So what are you looking for ??
__________________
Thanks Foot in Mouth ver 1.2.5 Onion |
|
#5
|
|||
|
|||
|
Many thanks for your time, f-i-m, but the form was not the cause of the problem - I was looking in the wrong place.
The form was returning correct data and I was collecting that data correctly, then I was adding it to the database. But I was not deleting the original contents of the database (his previous selections). So - of course - the old choices remained in place. Dooohhh ! A kick in the nether regions is definitely called for. Thanks again for your time. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > unchecking pre-checked html checkboxes to amend a selection list |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|