Paul Jr
12-18-2003, 09:53 PM
Well, I was looking at another thread here, and I wanted to try something out myself. I'm not actually going to use this anywhere; I'm attempting to learn JS bit by bit.
Here's what I got so far. What I want to happen is the user inputs their name, and once they click outside the text box, what they typed in will appear in the textarea, along with certain text I've specified. This should happen with every field, with every input being on a new line.
I don't get any errors, but nothing shows up.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test Layout</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-script-type" content="text/javascript" />
<meta http-equiv="content-language" content="en-us" />
<meta name="rating" content="general" />
<script type="text/javascript">
//<![CDATA[
var thing = "document.getElementById('Thing')"
var name = "document.getElementById('Name')"
var age = "document.getElementById('Age')"
var gender = "document.getElementById('Gender')"
function add1() {
thing.value='Name: '+name.value+'\n'
}
function add2() {
thing.value='Name: '+name.value+'\n'+'Age: '+age.value+'\n'
}
function add3() {
thing.value='Name: '+name.value+'\n'+'Age: '+age.value+'\n'+'Gender: '+gender.value+'\n'
}
//]]>
</script>
</head>
<body>
<form name="myForm" method="post" action="">
Name: <input type="text" id="Name" onblur="add1();" /> <br />
Age: <input type="text" id="Age" onblur="add2();" /> <br />
Gender: <input type="text" id="Gender" onblur="add3();" /> <br />
<h2 style="margin-bottom:0;padding-bottom:0;">Info</h2>
<textarea rows="10" cols="40" id="Thing"> </textarea>
</form>
</body>
</html>
Also, if anyone might have any idea on how to better do this, I'm open for any/all suggestions.
Thanks a lot! :)
Here's what I got so far. What I want to happen is the user inputs their name, and once they click outside the text box, what they typed in will appear in the textarea, along with certain text I've specified. This should happen with every field, with every input being on a new line.
I don't get any errors, but nothing shows up.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test Layout</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-script-type" content="text/javascript" />
<meta http-equiv="content-language" content="en-us" />
<meta name="rating" content="general" />
<script type="text/javascript">
//<![CDATA[
var thing = "document.getElementById('Thing')"
var name = "document.getElementById('Name')"
var age = "document.getElementById('Age')"
var gender = "document.getElementById('Gender')"
function add1() {
thing.value='Name: '+name.value+'\n'
}
function add2() {
thing.value='Name: '+name.value+'\n'+'Age: '+age.value+'\n'
}
function add3() {
thing.value='Name: '+name.value+'\n'+'Age: '+age.value+'\n'+'Gender: '+gender.value+'\n'
}
//]]>
</script>
</head>
<body>
<form name="myForm" method="post" action="">
Name: <input type="text" id="Name" onblur="add1();" /> <br />
Age: <input type="text" id="Age" onblur="add2();" /> <br />
Gender: <input type="text" id="Gender" onblur="add3();" /> <br />
<h2 style="margin-bottom:0;padding-bottom:0;">Info</h2>
<textarea rows="10" cols="40" id="Thing"> </textarea>
</form>
</body>
</html>
Also, if anyone might have any idea on how to better do this, I'm open for any/all suggestions.
Thanks a lot! :)