#1 jQuery Code to set hidden field value by IDval(); // this gives textbox value $("#myInputHidden"). val(getTxtValue); // this will set hidden field value alert(getValue); Above jQuery code will take textbox value into the variable getTxtValue and using . val() set its value to our hidden field.
You can simply use the jQuery :visible or :hidden selector to select all the visible or hidden elements in an HTML page. The jQuery :visible selector considered an element visible if they consume space in the document.
The <input type="hidden"> defines a hidden input field.
in jquery: $('#hiddenfieldid'). val(''); $('#Projectid').
Use val()
instead of text()
var hv = $('#h_v').val();
alert(hv);
You had these problems:
text()
for an input fieldx
rather than variable hv
If you don't want to assign identifier to the hidden field; you can use name or class with selector like:
$('input[name=hiddenfieldname]').val();
or with assigned class:
$('input.hiddenfieldclass').val();
This should work:
var hv = $('#h_v').val();
alert(hv);
html
<input type="hidden" value="hidden value" id='h_v' class='h_v'>
js
var hv = $('#h_v').attr("value");
alert(hv);
example
var hiddenFieldID = "input[id$=" + hiddenField + "]";
var requiredVal= $(hiddenFieldID).val();
var x = $('#h_v').val();
alert(x);
Closing the quotes in
var hv = $('#h_v).text();
would help I guess
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