Click to See Complete Forum and Search --> : Button to insert text
mjones
10-12-2003, 09:31 PM
Is there a script that will allow me to set up a page with several buttons that each generates a line of text into a text area? For example, button 1 would insert "bananas", button 2 for "oranges", and button 3 for "apples."
Mark
stepheno
10-12-2003, 10:01 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="JavaScript">
function populate(fruit){
if (form1.textarea.value = ''){
form1.textarea.value = fruit;
} else {
form1.textarea.value = form1.textarea.value + ' ' + fruit;
}
}
</script>
<body>
<table width="100%">
<form name="form1" method="post" action="">
<tr>
<td width="20%">
<input name="Bananas" type="button" value="Bananas" onClick="populate('Bananas')">
</td>
<td width="20%">
<input name="Apples" type="button" value="Apples" onClick="populate('Apples')">
</td>
<td width="60%">
<textarea name="textarea"></textarea>
</td>
</tr>
</form>
</table>
</body>
</html>