NoviceJavaUser
Programmer
Hello there,
I am fairly new to Javascript, all i want to do is add a carrage return to a value, IE when a dropdown option is selected, it writes some text in a text box, but i cannot get it to automatically carrage return so that when the next text box is selected it starts on a new line.
here is the code....
<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<SCRIPT type="text/javascript">
<!--
function putText(addText) {
var addText;
var revisedMessage;
var currentMessage = document.templates.messageBox.value;
revisedMessage = currentMessage+addText;
document.templates.messageBox.value=revisedMessage;
document.templates.messageBox.focus();
return;
}
</script>
</head>
<body>
<p> </p>
<form method="POST" name="templates">
<p>Is the PSTN OK?<select size="1" name="PSTN" tabindex="1" onChange="putText(this.value)">
<option selected value>*</option>
<option value='The PSTN is working OK.'>Yes</option>
<option value='The PSTN is not working.'>No</option>
</select></p>
<p>Has the service ever worked?<select size="1" name="Worked" tabindex="2" onChange="putText(this.value)">
<option selected>*</option>
<option value="The Service Has Worked in the past.">Yes</option>
<option value="The Service Has Never Worked.">No</option>
</select></p>
<p>
<textarea cols="50" rows="15" name="messageBox" wrap="virtual" class="text"></textarea></p>
<p>
<input type="reset" value="Reset" name="B1"></p>
</form>
<p> </p>
<p> </p>
</body></html>
Additional to that, it would be useful if i could have a window.alert when certain options are selected, IE if you were to say no to a particular question, it pops up an alert warning the user to do something, but does not pop up if they select yes option.
I look forward to your help.
I am fairly new to Javascript, all i want to do is add a carrage return to a value, IE when a dropdown option is selected, it writes some text in a text box, but i cannot get it to automatically carrage return so that when the next text box is selected it starts on a new line.
here is the code....
<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<SCRIPT type="text/javascript">
<!--
function putText(addText) {
var addText;
var revisedMessage;
var currentMessage = document.templates.messageBox.value;
revisedMessage = currentMessage+addText;
document.templates.messageBox.value=revisedMessage;
document.templates.messageBox.focus();
return;
}
</script>
</head>
<body>
<p> </p>
<form method="POST" name="templates">
<p>Is the PSTN OK?<select size="1" name="PSTN" tabindex="1" onChange="putText(this.value)">
<option selected value>*</option>
<option value='The PSTN is working OK.'>Yes</option>
<option value='The PSTN is not working.'>No</option>
</select></p>
<p>Has the service ever worked?<select size="1" name="Worked" tabindex="2" onChange="putText(this.value)">
<option selected>*</option>
<option value="The Service Has Worked in the past.">Yes</option>
<option value="The Service Has Never Worked.">No</option>
</select></p>
<p>
<textarea cols="50" rows="15" name="messageBox" wrap="virtual" class="text"></textarea></p>
<p>
<input type="reset" value="Reset" name="B1"></p>
</form>
<p> </p>
<p> </p>
</body></html>
Additional to that, it would be useful if i could have a window.alert when certain options are selected, IE if you were to say no to a particular question, it pops up an alert warning the user to do something, but does not pop up if they select yes option.
I look forward to your help.