using Javascript to get value from text box to div
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: using Javascript to get value from text box to div

  1. #1
    Join Date
    Jun 2009
    Posts
    3

    Question using Javascript to get value from text box to div

    Hi ,
    I have just started learning JS and here's where am stuck to know how to get a text from a text box and post it to a div .

    Here is the problem statement .I have a text box for names and a list for categories.What I want is when the user types a name and selects the category and clicks submit the name should appear under the list div.

    Example: Name : Bob
    List: Student(selected)
    Result: the name appears under Student div

    Simple? Would very much appreciate the code to do that, and please assume I know zero about JS - so I need it all
    Reply With Quote

  2. #2
    Join Date
    Apr 2009
    Posts
    598

    Smile Re: using Javascript to get value from text box to div

    Here it is:
    Code:
    <html>
    <head>
    <script language="JavaScript">
    function process_form1()
    {
      document.getElementById("result_name").innerHTML = document.getElementById("input_name").value;
      return true;
    }
    </script>
    </head>
    <body>
    <form id="form1">
    Name: <input type=text id="input_name" size=20>
    <p>
    List: <select name="lstbox1" size=1 onchange="test_lstbox_item(this)" style=width:200px>
    <option value="C" selected>Cat</option>
    <option value="S">Student</option>
    <option value="T">Teacher</option>
    </select>
    <p>Result: <div id="result_name"></div>
    <input type="button" value="OK" onClick="javascript:process_form1();">
    </form>
    </body>
    </html>

  3. #3
    Join Date
    Jun 2010
    Posts
    1

    Arrow Re: using Javascript to get value from text box to div

    thank you for this nice post
    it's relay helpful to me.
    webdesign

  4. #4
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,840

    Re: using Javascript to get value from text box to div

    Welcome to the forums zaggaustralia. Please remember to keep your posts relevant. This thread is a year old.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Tags for this Thread

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center