Setting text to a textbox in a form

Javascript coding ..

Moderators: macek, egami, gesf

moorstream
New php-forum User
New php-forum User
Posts: 5
Joined: Thu Jul 10, 2003 2:39 am

Setting text to a textbox in a form

Postby moorstream » Wed Oct 22, 2003 11:45 am

Hi

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?

/Moorstream

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

Postby liquedus » 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
mammal
New php-forum User
New php-forum User
Posts: 37
Joined: Wed Apr 02, 2003 1:31 am
Location: Hythe, UK

Use this code...

Postby mammal » 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 + " ";

*/
}

// -->
</script>

<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>
</select>
<textarea name="MyTextArea"></textarea>
</form>


Return to “JavaScript”

Who is online

Users browsing this forum: No registered users and 0 guests

cron