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
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>
Re: using Javascript to get value from text box to div
thank you for this nice post
it's relay helpful to me.
webdesign
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.