1 Attachment(s)
Write the value to the Hidden Field thru JS
Hi All,I wnat to set the HIDDEB FIELD VALUE THRU JS. But I am gettin the error,can anyboy help me out!
Code:
<input id="HiddenField1" type="hidden" value="" runat="server" />
Code:
var _textbox1= document.getElementById('<%= textbox1.ClientID %>');
document.getElementById('HiddenField1').value = _textbox1.value;
alert(document.getElementById('HiddenField1').value);
ERROR(IMAGE ATTACHED)
Re: Write the value to the Hidden Field thru JS
Code:
<script type="text/javascript" language="javascript">
function fixit()
{
var chk = document.getElementById("text1");
var hdchk = document.getElementById("HiddenField1");
alert(chk.value);
hdchk.value = chk.value;
alert(hdchk.value);
}
</script>
Quote:
<input id="HiddenField1" type="hidden" runat="server" />
<input id="text1" type="text" runat="server" />
<input type="button" value="check" onclick="javascript:fixit();return false;" />
i guess it's working fine..
i think you need to check one more time..
try this code...
hope it helps
Re: Write the value to the Hidden Field thru JS
Hey,
The reason that you are getting that error is that the getElementById is not finding the control that you are asking for.
Can you verify that the control is rendered to the client, with that Id. i.e. right click on the page, and View Source.
Gary