Forum Moderators: open

Message Too Old, No Replies

to move a text value to a div

using javascript

         

rubyangel

5:39 pm on Jun 12, 2009 (gmt 0)

10+ Year Member



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

PokeTech

1:03 am on Jun 16, 2009 (gmt 0)

10+ Year Member



<script type="text/javascript">
function PlaceInDiv() {
var getname = document.getElementById('name').value;
document.getElementById('div').innerHTML = "<strong>Name:</strong> "+getname+"<br />";
}
</script>

<strong>Student:</strong><hr>
<div id="div"></div>

<input type="text" id="name"><br />
<input type="submit" value="Submit" onclick="PlaceInDiv();">


Not quite sure if this is what your looking for, if not just explain it a little more.