Copy some HTML, with input boxes?

Discussion in 'JavaScript' started by Triexa, Dec 2, 2006.

  1. #1
    Say I have:

    
    <div id="abc">
        <input type="text" name="myname" value="TEST">
    </div>
    
    Code (markup):
    if I use abc.innerHTML, I won't get the new value for the text field (if changed by the user). What would be the best way to accomplish fetching the new value to "properly" copy the HTML?
     
    Triexa, Dec 2, 2006 IP
  2. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #2
    Using the "id" and "name" properties with "input" fied. That way works on Explorer and FireFox. Example:
    
    <html>
    <body>
      <div id="abc">
        <input type="text" id="myname" name="myname" value="TEST" size="11" maxlength="20"/>
        <br />
        <button type="button" onclick="JavaScript: alert( document.getElementById('myname').value );">Alert Value</button>
      </div>
    </body>
    </html>
    
    Code (markup):
     
    ajsa52, Dec 2, 2006 IP
  3. Triexa

    Triexa Active Member

    Messages:
    580
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    hmm... ya I guess so. I'll just add IDs I guess. Cause I have a lot of input fields. haha
     
    Triexa, Dec 2, 2006 IP
  4. sat123

    sat123 Banned

    Messages:
    1,600
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    0
    #4
    id(id of textbox).innerHTML or textbox_name.value(to be used bit differently...)
     
    sat123, Feb 23, 2007 IP