get textbox value via id

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ahmetbm
    New Member
    • Nov 2007
    • 9

    #1

    get textbox value via id

    hi;

    Code:
    function updateSpecials(num) {
    var priceValue = document.forms["formName"].price[num - 1].value;
    document.forms["formName"].special_price[num - 1].value = priceValue;
    }
    this function getiing the value of textbox via it's name, but i want to do it via textbox's id, any helps,

    thanks...
  • satas
    New Member
    • Nov 2007
    • 82

    #2
    Hi.

    Just use getElementById( ) method :
    [code=javascript]document.getEle mentById(id).va lue[/code]

    Comment

    • ahmetbm
      New Member
      • Nov 2007
      • 9

      #3
      in my form at all lines i have 2 textboxes and one's value will be written the other so how will we differ them?

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        The ID should be unique so document.getEle mentById will select the correct textbox.

        If you still have problems, post your form code.

        Comment

        • ahmetbm
          New Member
          • Nov 2007
          • 9

          #5
          thanks for suggestions, i defeated the problem with unique id

          regards.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Glad you got it working. Post to the forum again if you have more questions.

            Comment

            Working...