Results 1 to 3 of 3

Thread: Write the value to the Hidden Field thru JS

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2009
    Posts
    105

    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('<&#37;= textbox1.ClientID %>');
    document.getElementById('HiddenField1').value = _textbox1.value;
                     alert(document.getElementById('HiddenField1').value);
    ERROR(IMAGE ATTACHED)
    Attached Images Attached Images  
    Last edited by gtyagi; Mar 14th, 2010 at 11:45 AM.

  2. #2
    Hyperactive Member dnanetwork's Avatar
    Join Date
    Oct 2007
    Location
    Mumbai
    Posts
    349

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

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width