Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 07-21-2005, 11:26 AM Dropdown onclick
Jdawg's Avatar
Experienced Talker

Posts: 38
Location: NB, Canada
Trades: 0
Hello, Javascript is not my cup of tea but I'm faced with a client that wants it a certain way.

I need to hide/display a DIV when you click on a form dropdown. Here's the not functioning code.

Code:
<style type="text/css">
#one,#two,#three{visibility:hidden;position:absolute;height:200px;width:300px;}
</style>

<script type="text/javascript">
function radFlip(){
var l=document.firstForm.dropdown.radOne.length;
for(var i=0;i<l;i++){
var to_see=document.firstForm.dropdown.radOne[i].value;
if(document.firstForm.dropdown.radOne[i].selected){
document.getElementById(to_see).style.visibility="visible";
}else{
document.getElementById(to_see).style.visibility="hidden";
}
}
}
</script>

Code:
<form action="" name="firstForm" onclick="radFlip();"> 
<select name="dropdown">
	<option name="radOne" value="one" selected>One</option>
	<option name="radOne" value="two">Two</option>
	<option name="radOne" value="three">Three</option>
</select>
</form> 

<div id="one">test 1</div>
<div id="two">test 2</div>
<div id="three">test 3</div>
I think the first problem is the script is not recognizing the form, and the second is I don't know if the .selected will actually work.

If anyone could shed some light. THANKS!!!
__________________
Jdawg

Please login or register to view this content. Registration is FREE


"I know because I must know, it is my purpose" - keymaker
Jdawg is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-21-2005, 01:07 PM
WebcyteDesign's Avatar
Registered User

Posts: 159
Location: Hamilton
Trades: 0
http://aspnet.4guysfromrolla.com/articles/091504-1.aspx

That article should help you out. It did for me.
WebcyteDesign is offline
Reply With Quote
View Public Profile Visit WebcyteDesign's homepage!
 
Old 07-21-2005, 01:53 PM
Jdawg's Avatar
Experienced Talker

Posts: 38
Location: NB, Canada
Trades: 0
Thx for the link. Although this method won't help me since it uses a button to make the action instead of clicking on a drop down option. From the looks of it, the method of which the action is taking place (i.e. radio button, input button) makes a significan difference in the code.

Unfortunatly, I need it specifically for a drop down.
__________________
Jdawg

Please login or register to view this content. Registration is FREE


"I know because I must know, it is my purpose" - keymaker
Jdawg is offline
Reply With Quote
View Public Profile
 
Old 07-21-2005, 06:41 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
use the onSelect event in place of the onClick event.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Dropdown onclick
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25371 seconds with 12 queries