
September 2nd, 2005, 01:01 AM
|
|
Contributing User
|
|
Join Date: Apr 2007
Location: Miami, Fl. US
Posts: 522
Time spent in forums: 8 m 29 sec
Reputation Power: 2
|
|
|
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 |
|
|
|
<script language="JavaScript"> function showDiv( id ) { if ((daily_staffing.type.selectedIndex == 1) || (daily_staffing.type.selectedIndex == 6) || (daily_staffing.type.selectedIndex == 14)) { document.all[ id ].style.display = 'block'; } else { document.all[ id ].style.display = 'none'; document.daily_staffing.time_from.value=""; document.daily_staffing.time_to.value=""; document.daily_staffing.total_hours.value=""; } } </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.
|