Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

JavaScript intergrated with select menus

Script needs fixing for Opera



6:19 pm on Mar 13, 2003 (gmt 0)

10+ Year Member

I have a script to produce a URL from two variables; month and event type.

The script works fine in IE but, to my surprise doesn't respond in Opera.

The URL is generated when the user clicks an input button but nothing happens in Opera. 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";


and the form it is functioning on looks like this:


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


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


Would anyone be able to offer any solutions as to why it does not work in Opera and come up with a fix?

(Note: the script has not been tested in Netscape so I don't know if it works in Netscape)

Many Thanks


[edited by: tedster at 10:02 pm (utc) on Mar. 13, 2003]
[edit reason] make the url generic [/edit]


8:14 pm on Mar 13, 2003 (gmt 0)

10+ Year Member

Tested a variation of this in Opera and it worked fine.

function go(){
var L1 = document.theform.list1.options(list1.selectedIndex).value;
var L2 = document.theform.list2.options(list2.selectedIndex).value;
if (L1!= "#" && L2!= "#")
var url = "http://www.birdwatchnorthumbria.co.uk/events/" + L1 + L2 + ".htm";

IE - forgiving as it is - let you use syntax that, strictly speaking, is incorrect. For instance, if the select box allowed multiple select, it wouldn't have done what you intended.


9:47 pm on Mar 13, 2003 (gmt 0)

10+ Year Member

Hmm I updated the Jscript with that and tested it again and it still doesnt seem to work.

It may be a problem with the button or the fact that the form has no action specified?

Thanks for trying, any more offers?



10:11 am on Mar 15, 2003 (gmt 0)

10+ Year Member



8:36 pm on Mar 18, 2003 (gmt 0)

10+ Year Member

Somebody please help me out here!



8:47 pm on Mar 18, 2003 (gmt 0)

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member

hey psychomonkeyCK,

First I would change the function name away from go. It may be causing problems. Have you tried assigning the object instead of calling the method?

location.href= url;

I also thought that only jscript supported non array calls to selected indexes. This could also be an issue. I think you should use [] instead of () for the array to.

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

I don't think you need an action defined with Opera in the form tag.


Featured Threads

Hot Threads This Week

Hot Threads This Month