homepage Welcome to WebmasterWorld Guest from 54.198.33.96
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Making a script work in IE5
A stubborn Javascript needs sorting
psychomonkeyCK




msg:1474419
 11:11 am on May 8, 2003 (gmt 0)

I have the following script linked up to a pair of lists that generate a URL from the two selected options when the user clicks the "go" button. The Script is as follows:

function go(){
var L1 = document.theform.list1.value;
var L2 = document.theform.list2.value;
if (L1!= "#" && L2!= "#")
{
var url = "http://www.example.com/events/" + L1 + L2 + ".htm";
location.href(url);
}
}

And the dual list html code is as follows:

<form name="theform">
<select name="list1" size="1" style="background-color:#ffffff; color: #666666; width: 160px;">
<option value="#" SELECTED>-- Select Month --</option>
<option value="jan">January</option>
<option value="feb">February</option>
<option value="mar">March</option>
<option value="apr">April</option>
<option value="may">May</option>
<option value="jun">June</option>
<option value="jul">July</option>
<option value="aug">August</option>
<option value="sep">September</option>
<option value="oct">October</option>
<option value="nov">November</option>
<option value="dec">December</option>
</select>

<select name="list2" size="1" style="background-color:#ffffff; color: #666666; width: 160px;">

<option value="#" SELECTED>-- Select Event Type --</option>
<option value="ae">All Events</option>
<option value="de">Day Events</option>
<option value="wb">Weekends Breaks</option>
<option value="pt">Personalised Tours</option>

</select>

<input type="button" value="Go" onclick="go()"/>
</form>

My problem is that this setup only works in IE6 and not IE5 or Opera and I havn't tested netscape. Could someone with the technical expertise to fix this problem help me to solve this problem quickly as it is occuring on a website that is already live!

Many Thanks

Luke Winter

(Either Relpy or PM me please)

[edited by: tedster at 5:06 pm (utc) on May 8, 2003]

 

BlobFisk




msg:1474420
 11:51 am on May 8, 2003 (gmt 0)

Hey psychomonkeyCK,

Change the L1 and L2 variable declerations to:

var L1 = document.theform.list1.options[document.theform.list1.selectedIndex].value;
var L2 = document.theform.list2.options[document.theform.list2.selectedIndex].value;

And the redirect code to:

window.location=url;

And this should work fine now...

Tested in IE6, Mozilla 1.0, Opera 7 and NN4.7

psychomonkeyCK




msg:1474421
 9:05 pm on May 8, 2003 (gmt 0)

Thanks very much! Seems to work great in Opera now but I cannot test it in IE 5 till next week, I'll let you know how it performs.

CK

psychomonkeyCK




msg:1474422
 5:29 pm on May 10, 2003 (gmt 0)

Unfortunatly I have been reliably informed that the updated verison of the script still doesn't work in IE

Javascript Code:

function go(){
var L1 = document.theform.list1.options[document.theform.list1.selectedIndex].value;
var L2 = document.theform.list2.options[document.theform.list2.selectedIndex].value;
if (L1!= "#" && L2!= "#")
{
var url = "http://www.example.com/folder/" + L1 + L2 + ".htm";
window.location=url;
}
}

Dual List HTML Code:

<form name="theform">
<select name="list1" size="1" style="background-color:#ffffff; color: #666666; width: 160px;">
<option value="#" SELECTED>-- Select Month --</option>
<option value="jan">January</option>
<option value="feb">February</option>
<option value="mar">March</option>
<option value="apr">April</option>
<option value="may">May</option>
<option value="jun">June</option>
<option value="jul">July</option>
<option value="aug">August</option>
<option value="sep">September</option>
<option value="oct">October</option>
<option value="nov">November</option>
<option value="dec">December</option>
</select>

<select name="list2" size="1" style="background-color:#ffffff; color: #666666; width: 160px;">

<option value="#" SELECTED>-- Select Event Type --</option>
<option value="ae">All Events</option>
<option value="de">Day Events</option>
<option value="wb">Weekends Breaks</option>
<option value="pt">Personalised Tours</option>

</select>

<input type="button" value="Go" onclick="go()"/>
</form>

Could anyone have a shot at making this work in IE5 please?

Many Thanks

CK

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved