I want to either remove 2 hidden fields or set them to null in a form before a POST action is performed using onclick event on a checkbox.
This is what I have -
<input type="hidden" id="ci" name="ci" value="2"/>
<input type="hidden" id="pg" name="pg" value="prev"/>
<form:checkboxes path="choices" items="${lookups}" itemValue="id" itemLabel="label" element="li" **onclick="this.form.submit();"**/>
How do I modify my onclick event JS to support this ?
Thanks!
$("input[type='hidden']").each(function(){
$(this).reset();
});
.......................................................or......................................................
The below code is made up of javascript. This may work
oForm = getElementById('form_id');
var frm_elements = oForm.elements;
for (i = 0; i < frm_elements.length; i++)
{
field_type = frm_elements[i].type.toLowerCase();
switch (field_type)
{
case "text":
case "password":
case "textarea":
case "hidden":
frm_elements[i].value = "";
break;
case "radio":
case "checkbox":
case "select-one":
case "select-multi":
default:
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With