Friday, February 23, 2024
 Popular · Latest · Hot · Upcoming
180
rated 0 times [  187] [ 7]  / answers: 1 / hits: 29602  / 15 Years ago, tue, may 12, 2009, 12:00:00

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);
}

More From » jquery

 Answers
27

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')

[#99554] Thursday, May 7, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
marcos

Total Points: 331
Total Questions: 106
Total Answers: 104

Location: Gabon
Member since Sat, Jul 25, 2020
4 Years ago
marcos questions
Thu, Feb 24, 22, 00:00, 2 Years ago
Sat, Apr 17, 21, 00:00, 3 Years ago
Mon, Feb 1, 21, 00:00, 3 Years ago
Tue, Jan 26, 21, 00:00, 3 Years ago
Wed, Jan 6, 21, 00:00, 3 Years ago
;