CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2009

    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

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

    Here it is:
    <script language="JavaScript">
    function process_form1()
      document.getElementById("result_name").innerHTML = document.getElementById("input_name").value;
      return true;
    <form id="form1">
    Name: <input type=text id="input_name" size=20>
    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>
    <p>Result: <div id="result_name"></div>
    <input type="button" value="OK" onClick="javascript:process_form1();">

  3. #3
    Join Date
    Jun 2010

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

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

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

    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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.