...

View Full Version : <select> behaves in FF not IE



700lbGorilla
12-30-2006, 11:33 PM
Can anybody tell me why this isn't working in IE, I want it to go to the url when the option is clicked. Those addresses are default, but doesn't matter it doesn't go to them anyways. I've taken the ()'s out too, doesn't work in IE that way either.


<select>
<option>
-------- View More Poems --------
</option>
<option onclick='location.href=("http://www.wordlocker.com/poems/poemtitle")'>
&lt;-- Previous Poems
</option>
<option onclick='location.href=("http://www.wordlocker.com/poems/poemtitle")'>
One Year
</option>
<option onclick='location.href=("http://www.wordlocker.com/poems/poemtitle")'>
The Conversation...
</option>
<option onclick='location.href=("http://www.wordlocker.com/poemtitle")'>
That's Okay
</option>
<option onclick='location.href=("http://www.wordlocker.com/poems/poemtitle")'>
The Riddle
</option>
<option onclick='location.href=("http://www.wordlocker.com/poems/poemtitle")'>
They're Swimming
</option>
</select>

coothead
12-31-2006, 12:04 AM
Hi there 700lbGorilla,

try it like this...


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">
window.onload=function() {
document.getElementById('poems').onchange=function() {
if(this.value!='') {
location.href=this.value;
}
}
}
</script>

</head>
<body>

<div>
<select id="poems">
<option value="">-------- View More Poems --------</option>
<option value="http://www.wordlocker.com/poems/poemtitle">&lt;-- Previous Poems</option>
<option value="http://www.wordlocker.com/poems/poemtitle">One Year</option>
<option value="http://www.wordlocker.com/poems/poemtitle">The Conversation...</option>
<option value="http://www.wordlocker.com/poemtitle">That's Okay</option>
<option value="http://www.wordlocker.com/poems/poemtitle">The Riddle</option>
<option value="http://www.wordlocker.com/poems/poemtitle">They're Swimming</option>
</select>
</div>

</body>
</html>

coothead

700lbGorilla
12-31-2006, 01:06 AM
Thank you, worked perfectly!

nemo5
12-31-2006, 05:44 PM
It does not work, because the onclick event does not get triggered in IE. You have to use onchange event to make it compatible



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum