Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Hidden field value in javascript

Hidden field value in javascript

Scheduled Pinned Locked Moved JavaScript
csharpjavascripttoolsquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vkEE
    wrote on last edited by
    #1

    Hi, This has both C# and Javascript. Not sure if it is the correct forum. I have a hidden field value on an apsx page, which is populated on PageLoad. I am trying to request this value in javascript. The value does load from PageLoad, because I can see this value on page view source for the hidden aspx field. But when i try to request this value in javascript, the value is null. I know it is null since I am using alert statements to see this value. Am I missing a syntax? Many thanks!!

    <script type="text/javascript">
    <!--
    var emailAddress = document.getElementById('<%=hfEmail.ClientID%>');
    alert('Hi!');
    alert('Hi - ' + emailAddress);
    alert(emailAddress.value);

        //--&gt;
    

    </script></pre>

    ASPX code

    T Kornfeld Eliyahu PeterK 2 Replies Last reply
    0
    • V vkEE

      Hi, This has both C# and Javascript. Not sure if it is the correct forum. I have a hidden field value on an apsx page, which is populated on PageLoad. I am trying to request this value in javascript. The value does load from PageLoad, because I can see this value on page view source for the hidden aspx field. But when i try to request this value in javascript, the value is null. I know it is null since I am using alert statements to see this value. Am I missing a syntax? Many thanks!!

      <script type="text/javascript">
      <!--
      var emailAddress = document.getElementById('<%=hfEmail.ClientID%>');
      alert('Hi!');
      alert('Hi - ' + emailAddress);
      alert(emailAddress.value);

          //--&gt;
      

      </script></pre>

      ASPX code

      T Offline
      T Offline
      twseitex
      wrote on last edited by
      #2

      check emailAddress emailAddress null pointer ? property .value exists ? range of value of .value ? HTML funktion document.getElementById() uses param during parsing of document so '<%=hfEmail.ClientID%>' must be a real ID or filled BEFORE parsing javascript. put javascript at end of body, no in head (head is parsed at first before body). .... what you want //--> </script></pre> // where is <pre>

      1 Reply Last reply
      0
      • V vkEE

        Hi, This has both C# and Javascript. Not sure if it is the correct forum. I have a hidden field value on an apsx page, which is populated on PageLoad. I am trying to request this value in javascript. The value does load from PageLoad, because I can see this value on page view source for the hidden aspx field. But when i try to request this value in javascript, the value is null. I know it is null since I am using alert statements to see this value. Am I missing a syntax? Many thanks!!

        <script type="text/javascript">
        <!--
        var emailAddress = document.getElementById('<%=hfEmail.ClientID%>');
        alert('Hi!');
        alert('Hi - ' + emailAddress);
        alert(emailAddress.value);

            //--&gt;
        

        </script></pre>

        ASPX code

        Kornfeld Eliyahu PeterK Offline
        Kornfeld Eliyahu PeterK Offline
        Kornfeld Eliyahu Peter
        wrote on last edited by
        #3

        Can you show the PageLoad function?

        I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is (V).

        "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

        V 1 Reply Last reply
        0
        • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

          Can you show the PageLoad function?

          I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is (V).

          V Offline
          V Offline
          vkEE
          wrote on last edited by
          #4

          This is the syntax, to be placed with in the body of email: var createdate = '<%=hdnCreateDate.Value%>';

          A 1 Reply Last reply
          0
          • V vkEE

            This is the syntax, to be placed with in the body of email: var createdate = '<%=hdnCreateDate.Value%>';

            A Offline
            A Offline
            Amir Hamza Md Kayes
            wrote on last edited by
            #5

            try it in jquery ready function. $(document).ready(function() { var hiddenVal=$("#YourId").val(); }); if you use master page in aspx, then you can find the element by name also. $("input[name='elementName']")

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups