Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

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 Codewalkers Forums Sponsor:
  #1  
Old September 2nd, 2005, 01:01 AM
jweizenblut jweizenblut is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Miami, Fl. US
Posts: 522 jweizenblut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 29 sec
Reputation Power: 2
Send a message via AIM to jweizenblut Send a message via Yahoo to jweizenblut
Show SPAN depending on value

I have a form select object that used to loads it's values from a text file. I had some code that depending on the selectIndex it will display additional inputs. Code as follows:
php Code:
Original - php Code
  1.  
  2. <script language="JavaScript">
  3. function showDiv( id ) {
  4. if ((daily_staffing.type.selectedIndex == 1) || (daily_staffing.type.selectedIndex == 6) || (daily_staffing.type.selectedIndex == 14))
  5. {
  6. document.all[ id ].style.display = 'block';
  7. }
  8. else
  9. {
  10. document.all[ id ].style.display = 'none'
  11. document.daily_staffing.time_from.value="";
  12. document.daily_staffing.time_to.value="";
  13. document.daily_staffing.total_hours.value="";
  14. }
  15. }
  16. </script>


Problem that I have now is that with my the new mySQL server, I now load the list from a database and can easily add more options to the drop-down. Since the same 3 basic options will be the only ones that make the above span appear, I want to be able to modify the if so that instead of using the selectedIndex it uses the actual value. For example: selectedIndex 1 will always have the value of "AL". So, I want to have the span show regardless of the index location of the "AL" value.

Hopefully I explained myself properly.

Any help would be appreciated.

Reply With Quote
  #2  
Old September 2nd, 2005, 10:18 AM
spud spud is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Melbourne, Australia
Posts: 163 spud User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Show SPAN depending on value

you could try something like
php Code:
Original - php Code
  1.  
  2. <script language="JavaScript">
  3. function showDiv( id ) {
  4. if ((daily_staffing.type.options[daily_staffing.type.selectedIndex].value == "AL"))
  5. {
  6. document.all[ id ].style.display = 'block';
  7. }
  8. else
  9. {
  10. document.all[ id ].style.display = 'none'
  11. document.daily_staffing.time_from.value="";
  12. document.daily_staffing.time_to.value="";
  13. document.daily_staffing.total_hours.value="";
  14. }
  15. }
  16. </script>


Reply With Quote
  #3  
Old September 2nd, 2005, 03:43 PM
jweizenblut jweizenblut is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Miami, Fl. US
Posts: 522 jweizenblut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 29 sec
Reputation Power: 2
Send a message via AIM to jweizenblut Send a message via Yahoo to jweizenblut
RE: Show SPAN depending on value

Unfortunately that didn't work. Any other ideas?

Reply With Quote
  #4  
Old September 3rd, 2005, 05:30 AM
spud spud is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Melbourne, Australia
Posts: 163 spud User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Show SPAN depending on value

sorry, try
php Code:
Original - php Code
  1.  
  2. daily_staffing.type.options[daily_staffing.type.options.selectedIndex].value

if that doesn't work, then i'm sorry.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Show SPAN depending on value


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 2 hosted by Hostway