Created
January 7, 2010 13:14
-
-
Save johnhmj/271221 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>JavaScript</title> | |
<script language="javascript" type="text/javascript"> | |
<!-- | |
// set value and get value | |
function setTextBox(form, value) | |
{ | |
form.tb.value = value; | |
} | |
function setTextArea(form, value) | |
{ | |
form.ta.value = value; | |
} | |
function getTextBox(form) | |
{ | |
return form.tb.value; | |
} | |
function getTextArea(form) | |
{ | |
return form.ta.value; | |
} | |
function setText(form) | |
{ | |
if ( form.tb.value.size == 0 ) | |
{ | |
// clear text area | |
setTextArea( form, ""); | |
return; | |
} | |
// set value | |
setTextArea( form, getTextBox(form)); | |
} | |
// initialize | |
function Initialize(form) | |
{ | |
setTextBox( form, 'input text'); | |
setTextArea( form, ''); | |
} | |
// reload whole page | |
function Reload(form) | |
{ | |
location.reload(); | |
} | |
//--> | |
</script> | |
</head> | |
<body> | |
<!--//--> | |
<form name="myform"> | |
<input type="text" name="tb" value="input text" onmousedown="setTextBox( this.form, '');setTextArea( this.form, '');"> | |
</input> | |
<input type="button" value="OK" onclick="setText(this.form);"> | |
</input><br> | |
<textarea name="ta" readonly="readonly"></textarea><br> | |
<input type="button" value="Cancel" onclick="Reload(this.form);Initialize(this.form);"> | |
</input> | |
</form> | |
<!--//--> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment