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
    Posts
    3

    Question using JS 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

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

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

    I guess by JS you mean JavaScript which means you are in the wrong forum, this is a Java forum. Javascript is something altogether different. For JavaScript you should probably be in the client side scripting forum.

    I've requested the mods move this thread for you.

  3. #3
    Join Date
    Jun 2009
    Posts
    3

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

    thank you so much for your guidance ,am very new to this stuff.hope you have a nice day

  4. #4
    Join Date
    Feb 2008
    Posts
    966

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

    keang is right, but since we don't have an admin in this section to move the thread I'll try to help you real quick (xeel reads this forum and is good as well at this).

    You need to give the text box either an id or a styleId (depending on what type of element you are using).

    Have an input field
    <html:input name="nameInputField" id="nameField" />

    Inside the div have a text field
    <html:text name="myText" styleId="text" />

    Then in the javascript for the button you perform something like:
    var name = document.getElementById("nameField");
    document.getElementById("text").value = name;

    Play around with this. Google searches will find thousands of pages to help on this subject also, with better tutorials and examples than the one I provided.

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
  •  





Click Here to Expand Forum to Full Width

Featured