Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-12-2010, 06:04 PM   PM User | #1
sharp_mac
New to the CF scene

 
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
sharp_mac is an unknown quantity at this point
Question hide / show not working on select tags

Greetings,

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

</code>

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>
</select>

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

</code>

my javascript at the bottom of the page before the </body>
<code class="javascript">
<!--
JAVASCRIPT AT END OF PAGE BEFORE CLOSING </body>
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
$("#"+arrdep+"dep_win_airport"+trip).show();
case 2: //Port of Miami
$("#"+arrdep+"_win_cruse"+trip).show();
case 4: //Port Canaveral
$("#"+arrdep+"_win_cruse"+trip).show();
case 5: //door drop off
$("#"+arrdep+"_win_door"+trip).show();
case 6: //Door Pick Up

case 7://Airport NO FLIGHT
default:
$("#"+arrdep+"_window"+trip).hide();
$("#"+arrdep+"_info_"+trip).hide();
$("#"+arrdep+"_win_door"+trip).hide();
$("#"+arrdep+"_win_cruse"+trip).hide();
$("#"+arrdep+"_win_airport"+trip).hide();
$("#"+arrdep+"info_"+trip).val("Supply Address");
}; //end switch splitVal
}; //end function showBox
</script>
</code>
sharp_mac is offline   Reply With Quote
Reply

Bookmarks

Tags
hide show not working, html, jquery, php

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:17 AM.


Advertisement
Log in to turn off these ads.