JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 6th, 2002, 01:52 PM
Jefferrs Jefferrs is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 2 Jefferrs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
JavaScript SELECT box problem

Hi y'all

Can anyone figure out a problem with this? It's probably stupidly simple but I can't spot it.

Look at URL - you can see that the script is meant to display a message on the right-hand side of the page, depending on what is chosen from the drop-down box on the left. BUT the script won't let you select anything other than the very last item (in IE6). Why?

Here's the code:


Code:
<textarea name="add" style="float:right;background-color:white;color:black;font-family:Arial,Helvetica,Monaco;size:normal;border:0px;width:350px;overflow:visible">
</textarea>
<form method="post" action="" name="listpanes">
	<select name="comID" onChange="changeDescription()">
		<option value="">+select+</option>
		<option value="">msg one</option>
		<option value="">msg two</option>
	</select>
</form>

<SCRIPT LANGUAGE="JavaScript" type="text/javascript">

function changeDescription() {
	if(document.listpanes.comID.selectedIndex="1") {	
	add.value='Message ONE';
	add.disabled=1;
	}
	if(document.listpanes.comID.selectedIndex="2") {	
	add.value='Message TWO';
	add.disabled=1;
	}
}

</script>

Last edited by Jefferrs : February 6th, 2002 at 01:55 PM.

Reply With Quote
  #2  
Old February 6th, 2002, 05:21 PM
Jonathon's Avatar
Jonathon Jonathon is offline
T-Shirt Tragic
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2001
Location: Melbourne, Australia
Posts: 886 Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level)Jonathon User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 6 h 53 m 39 sec
Reputation Power: 320
Send a message via Skype to Jonathon
most of your html code was missing from the document, the textarea element was outside the form tags and you were trying to reference a form element without first referencing the form object ...
try this-
Code:
<html>
<head>
<title></title>
<script LANGUAGE="JavaScript" type="text/javascript">

function changeDescription() {
    
    if (document.listpanes.comID.selectedIndex > 0)
        document.listpanes.add.value=document.listpanes.comID.value;

}
</script>
</head>
<body>



<form method="post" action="" name="listpanes">

<select name="comID" onChange="changeDescription()">
<option value="">+select+</option>
<option value="Message ONE">msg one</option>
<option value="Message TWO">msg two</option>
</select>

<textarea name="add"></textarea>
</form>
</body>
</html>

Reply With Quote
  #3  
Old February 6th, 2002, 07:19 PM
Jefferrs Jefferrs is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 2 Jefferrs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > JavaScript SELECT box problem

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap