Setting text to a textbox in a form

Javascript coding ..

Moderators: egami, macek, gesf

Post Reply

Wed Oct 22, 2003 11:45 am


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?


php-forum Active User
php-forum Active User
Posts: 264
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada

Thu Oct 23, 2003 3:51 am

can you post some code?

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

User avatar
New php-forum User
New php-forum User
Posts: 37
Joined: Wed Apr 02, 2003 1:31 am
Location: Hythe, UK

Tue Nov 11, 2003 7:25 am

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>

Post Reply