View Full Version : hide / show not working on select tags

11-12-2010, 07:04 PM

I recently learned that the <option> tags can not use the onclick attribute inside of IE. This works great for firefox, but sadly not a single version of internet explorer supports it (from what I am told via countless Google searches).

I have been modifying my attempit at a solution to use the <select> tag with the attribute onchange. Maybe I am casing this wrong, or not seeing a solution as the below code does not operate in any browser,
and no errors are reported back through firebug or IE.

Excuse my sloopy attempt at {smarty tags} this script is written in a bunch of PHP object->vales and to save space cored the issue down to it's basics.

On change of the select box, the value="5-28" is sent to javascript showBox to split the number away from the id_trips and only focus on the locations (the number before the '-' .

IF the location matches the switch value then the box should show / hide or value change. The IDs are all correct I just think that there is a ' or a " or something off as I am not a javascript expert.

my SQL return values
<code class="php">
//PHP VARIABLES from QUERY sample loop 1
trip-number = 200
locations = 5
id_trips = 28


my HTML form loop
<code class="html">

{BEGIN LOOP 'trips'}
<!--HTML form for {trip-number} -->
<form id="trip{trip-number}" method="post" action="#">

<select id="depid{trip-number}"
name="depId" class="inputed greybig required"
onchange="showBox(this.value, '{trip-number}', 'dep');">
<option value="">Select Time</option>
<option value="{locations}|{id_trip}">{trip-time}</option>

<!--/HTML form for {trip-number} -->
{/END LOOP 'trips'}


my javascript at the bottom of the page before the </body>
<code class="javascript">
I am using the jQuery Tools latest build 1.4.2
pull value, split and process for hide / show options
<script type="text/javascript">
function showBox(val, trip, arrdep){
var splitVal = val.split("-");
switch (splitVal[0]){
case 1: //Airport
case 2: //Port of Miami
case 4: //Port Canaveral
case 5: //door drop off
case 6: //Door Pick Up

case 7://Airport NO FLIGHT
$("#"+arrdep+"info_"+trip).val("Supply Address");
}; //end switch splitVal
}; //end function showBox