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. changing input value atrribute

changing input value atrribute

Scheduled Pinned Locked Moved JavaScript
tools
5 Posts 3 Posters 2 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.
  • S Offline
    S Offline
    Sonar87
    wrote on last edited by
    #1

    I Need to get the value attribute to change to different numbers that I want to change in script parts based on user input so that the form will post a message to a different place depening on what they choose, but whatever I try it won't change, or at least not in time so that it posts right document.getElementBytagName("member_id").value="40603"; Hello.

    D 1 Reply Last reply
    0
    • S Sonar87

      I Need to get the value attribute to change to different numbers that I want to change in script parts based on user input so that the form will post a message to a different place depening on what they choose, but whatever I try it won't change, or at least not in time so that it posts right document.getElementBytagName("member_id").value="40603"; Hello.

      D Offline
      D Offline
      daveyerwin
      wrote on last edited by
      #2

      document.getElementsByTagName try it this way (it will probably work but there is no gaurentee that the dom will be ready, you should move the script block to the end ot the page)

      <input type='hidden' name='member_id' id='number' value='***' />
      <script type="text/javascript">
      document.getElementById("number").value="40603";
      </script>

      S 1 Reply Last reply
      0
      • D daveyerwin

        document.getElementsByTagName try it this way (it will probably work but there is no gaurentee that the dom will be ready, you should move the script block to the end ot the page)

        <input type='hidden' name='member_id' id='number' value='***' />
        <script type="text/javascript">
        document.getElementById("number").value="40603";
        </script>

        S Offline
        S Offline
        Sonar87
        wrote on last edited by
        #3

        Thanks a lot, it worked. One more question.. varibles.. Tried asigning it one like this: int num = 4321; document.getElementById("number").value=num; but that way didn't do it..

        P 1 Reply Last reply
        0
        • S Sonar87

          Thanks a lot, it worked. One more question.. varibles.. Tried asigning it one like this: int num = 4321; document.getElementById("number").value=num; but that way didn't do it..

          P Offline
          P Offline
          PoojaBorhade
          wrote on last edited by
          #4

          Declare the variable as : var num;

          S 1 Reply Last reply
          0
          • P PoojaBorhade

            Declare the variable as : var num;

            S Offline
            S Offline
            Sonar87
            wrote on last edited by
            #5

            Hmm thought thats what I did the first time without getting anywhere.. Was 2 am though. Thanks.

            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