SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2005
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ajax - JS textbox

    I have a form and i want to get all the contents from it (OnChange) and put it in an array.
    Afterwards i want to send it to another file that will be included on the homepage.

    Code:
    <input type="text" name="name" id="name" onchange="getContents('name');">
    
    function getContents(id){
    	alert(document.getElementById(id).value);
    }
    Now instead of the alert i want to put all the contents in an array and return the values to another file.

    I hope someone can help, thank you.

  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2007
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want the text to appear as you type, you could use onkeyup.

    HTML Code:
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Text Box Changes</title>
    <script type="text/javascript">
    	window.onload = function() {
    		document.getElementById("txt1").onkeyup = function() {
    			document.getElementById("pTarget").innerHTML =  this.value;
    		}
    	}
    </script>
    </head>
    <body>
    <p>Type in the box: <input type="textbox" id="txt1" /></p>
    <p id="pTarget"></p>
    </body>
    </html>

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2005
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry about the edit and thank you for the solution.

    But now i have a little problem with all the contents (like 8 textboxes).


Bookmarks

Posting Permissions

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