JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 17th, 2004, 06:58 PM
Pineriver Pineriver is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 5 Pineriver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 32 m 12 sec
Reputation Power: 0
Question Select field does not seem to select

I have this nice dynamic select field that when a user clicks on a selection
it shows the <div> according to the value. There is just one problem, as you can see
I have the menu selected as default on the "Beach" option, now when the page first loads it does not
display the code that is for the beach <div> a user would have to click on another option and then click back.
Would anyone know how they may be able to modify this so by default it would also display the Beach code?

Code:
 <script>
function showForm(index){
frms=document.getElementsByTagName('div')
for (i=0;i<frms.length;i++)
  frms[i].style.display='none'
frms[index].style.display='block'
}
</script>
<select size="5" onchange="showForm(this.options[selectedIndex].value)">
<option value="1">Sand</option>
<option value="0" selected>Beach</option>
</select>
<div name="item" style="display:'none'">Code for Sand
</div>
<div name="item" style="display:'none'">Code for Beach
</div>


Thanks

Reply With Quote
  #2  
Old August 25th, 2004, 07:40 AM
Jackot29 Jackot29 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Paris, FRANCE
Posts: 29 Jackot29 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 32 m 10 sec
Reputation Power: 0
Wink

Very simple,

You've to change :
<div name="item" style="display:'none'">Code for Sand</div>
by :
<div name="item" style="display:'block'">Code for Sand</div>

(I also think that you made an inversion beetween your two divs (???))

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Select field does not seem to select


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway