I have a hidden input variable called str.
I am assigning "abc" value to it.
Then I try to assign null value or let's say null reference to it. But I couldn't.
Edit
part of code.
Hidden Field...
<input id="str" name="str" type="hidden" value="" />
I also use jQuery.
if ($(str).val() == "abc") {
$("#str").val(null);
}
I'm not sure nulling the value is meaningful - you should either blank the value, or delete the whole field (not just the value).
Based on the example code you provided...
For example:
$("#str").val('')
or
$("#str").remove()
Another option, if you may need to toggle the field on or off (so rather than deleting & re-creating) would be disabling the field - disabled fields don't get submitted with the form.
$("#str").attr('disabled','disabled')
and
$("#str").removeAttr('disabled')
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