Skip to content

Instantly share code, notes, and snippets.

@johnhmj
Created January 7, 2010 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnhmj/271221 to your computer and use it in GitHub Desktop.
Save johnhmj/271221 to your computer and use it in GitHub Desktop.
<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