Click to See Complete Forum and Search --> : optgroup form element doesn't trigger my pages


Vogan Gaudo
11-19-2007, 01:20 PM
What should I add to my form element
to make this JAVA script

function goToURL(form)
{

var myindex=form.dropdownmenu.selectedIndex
if(!myindex=="")
{
window.location.href=form.dropdownmenu.options[myindex].value;


}
}

trigger the appropriate page?

Changing value to eg value"Brugge.htm" doesn't do so.

Or do I need another JAVA script all together?


<form>
<select name="destination" size="27" class="dest_select">
<optgroup class="destit" label="Belgium (City Tours)">
<option class="optsup" value="Brugge" onClick="Brugge.htm">Brugge</option>
<option class="optsup" value="Brussel">Brussel</option>
<option class="optsup" value="Gent">Gent</option>
<option class="optsup" value="Leuven">Leuven</option>
<option class="optsup" value="Oostende">Oostende</option>
</optgroup>
<optgroup class="destit" label="Belgium (Coast)">
<option class="optsup" value="De_Haan">De Haan</option>
<option class="optsup" value="De_Panne">De Panne</option>
<option class="optsup" value="Knokke">Knokke</option>
<option class="optsup" value="Oostende">Oostende</option>
<option class="optsup" value="Zeebrugge">Zeebrugge</option>
</optgroup>
<optgroup class="destit" label="Canada (Alberta)">
<option class="optsup" value="Rockies">Rocky Mountains</option>
</optgroup>
<optgroup class="destit" label="Canada (British Columbia)">
<option class="optsup" value="Rockies">Rocky Mountains</option>
<option class="optsup" value="Gulf Islands">Gulf Islands</option>
</optgroup>
<optgroup class="destit" label="Great Britain (England)">
<option class="optsup" value="Lake District">Lake District</option>
<option class="optsup" value="Yorkshire Dales">Yorkshire Dales</option>
</optgroup>
</select>
</form>

Fang
11-19-2007, 02:02 PM
onclick in the option can not be used. IE does not fire any events on option elements.
The select must have the onchange event.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="be">
<head>
<title>form url</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript">
function goToURL(form)
{
window.location.href=form.value+'.html';
}
</script>

</head>
<body>

<form>
<select onchange="goToURL(this);" name="destination" size="27" class="dest_select">
<optgroup class="destit" label="Belgium (City Tours)">
<option class="optsup" value="Brugge">Brugge</option>
<option class="optsup" value="Brussel">Brussel</option>
<option class="optsup" value="Gent">Gent</option>
<option class="optsup" value="Leuven">Leuven</option>
<option class="optsup" value="Oostende">Oostende</option>
</optgroup>
<optgroup class="destit" label="Belgium (Coast)">
<option class="optsup" value="De_Haan">De Haan</option>
<option class="optsup" value="De_Panne">De Panne</option>
<option class="optsup" value="Knokke">Knokke</option>
<option class="optsup" value="Oostende">Oostende</option>
<option class="optsup" value="Zeebrugge">Zeebrugge</option>
</optgroup>
<optgroup class="destit" label="Canada (Alberta)">
<option class="optsup" value="Rockies">Rocky Mountains</option>
</optgroup>
<optgroup class="destit" label="Canada (British Columbia)">
<option class="optsup" value="Rockies">Rocky Mountains</option>
<option class="optsup" value="Gulf Islands">Gulf Islands</option>
</optgroup>
<optgroup class="destit" label="Great Britain (England)">
<option class="optsup" value="Lake District">Lake District</option>
<option class="optsup" value="Yorkshire Dales">Yorkshire Dales</option>
</optgroup>
</select>
</form>
</body>
</html>

Vogan Gaudo
11-19-2007, 03:05 PM
Awesome. Tx.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

works too

Vogan Gaudo
11-19-2007, 03:11 PM
Previous script made my password box jump to a different size.

Changing 2

<SCRIPT LANGUAGE="JavaScript">

function goToURL(form)
{
window.location.href=form.value+'.htm';
}
</script>

brought it back to it's original size.


Pretty strange he?