Page 1 of 1

Setting text to a textbox in a form

Posted: Wed Oct 22, 2003 11:45 am
by moorstream

From a javascript function I try to set a value from a dropdownmenu to a textbox, but I get this error message saying that:

document.mailForm.txtFrom is null or not an object

What am I doing wrong?


Posted: Thu Oct 23, 2003 3:51 am
by liquedus
can you post some code?

(are you using document.yourFormName.yourFormElement.options[selectedIndex].value for drop down list)

Use this code...

Posted: Tue Nov 11, 2003 7:25 am
by mammal
Use this - all tested....

Code: Select all

<script language="javascript">
<!-- Begin
function FillTextArea () {

var selection = document.MyForm.MySelectBox.value;
document.MyForm.MyTextArea.value = selection;

/* If you want to add the values on, use:

var selection = document.MyForm.MySelectBox.value;
var textarea_contents = document.MyForm.MyTextArea.value;
document.MyForm.MyTextArea.value = textarea_contents  + selection + " ";


// -->

<form name="MyForm">
<select name="MySelectBox" onchange="javascript:FillTextArea()">
<option value="">Please Select</option>
<option value="The">The</option>
<option value="Monkey">Monkey</option>
<option value="Eats">Eats</option>
<option value="Bananas">Bananas</option>
<textarea name="MyTextArea"></textarea>