-
June 12th, 2009, 02:17 PM
#1
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
-
June 13th, 2009, 02:51 AM
#2
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>
-
June 23rd, 2010, 03:58 AM
#3
Re: using Javascript to get value from text box to div
thank you for this nice post
it's relay helpful to me.
webdesign
-
June 23rd, 2010, 08:23 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|