Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 basic js . nearly there !
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

chumbawumba
Junior Member

United Kingdom
304 Posts

Posted - 09 September 2004 :  16:47:18  Show Profile
Basic javascript question. Need someone to point out the bleeding obvious to me !

I have a "select" menu on my form. Underneath that I have a textfield. I want the label of the select menu to display in the textfield, when an item is selected from the select menu.

code snippet ......


<script language="JavaScript1.2"> 

 function verifyInput() {
 var s;
 var s = form1.actid.text; 
 form1.expTitle.value = s;
 
 }
</script>

<select name="actid" onChange=verifyInput()>
<option value1> label1</option>
<option value2> label2</option>
</select>

<input name="expTitle" type="text" size="32" maxlength="50">



The code above works, but it puts the value of the select menu into the textbox and not the label. how do i change this !!!????

HuwR
Forum Admin

United Kingdom
20600 Posts

Posted - 09 September 2004 :  20:34:30  Show Profile  Visit HuwR's Homepage
try
function verifyInput() {
var s;
var s = form1.actid.value;
form1.expTitle.value = s;

}
Go to Top of Page

chumbawumba
Junior Member

United Kingdom
304 Posts

Posted - 10 September 2004 :  06:26:54  Show Profile
Hi Huw. That puts the value (e.g. value1) in the textbox, and not the label. My example above puts "undefined" in the textbox.
Go to Top of Page

chumbawumba
Junior Member

United Kingdom
304 Posts

Posted - 10 September 2004 :  06:44:29  Show Profile
Google is my master...



function verifyInput() {

var s = form1.actid.options[form1.actid.selectedIndex].text;
form1.expTitle.value = s;

}
</SCRIPT>

Go to Top of Page

HuwR
Forum Admin

United Kingdom
20600 Posts

Posted - 10 September 2004 :  08:30:56  Show Profile  Visit HuwR's Homepage
quote:
Originally posted by chumbawumba

Hi Huw. That puts the value (e.g. value1) in the textbox, and not the label. My example above puts "undefined" in the textbox.


My mistake, I misread your post
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.32 seconds. Powered By: Snitz Forums 2000 Version 3.4.07