...

View Full Version : Select Box, Doesn't Work In IE



Clive91
10-16-2006, 12:19 AM
function sendpm()
{
var top = window.document.pm.fto.selectedIndex;
var topi = window.document.pm.fto.options[top].value;
loc = "newpm.php?fto=" + topi;
window.open(loc,"pm","height=340,width=629");
}I have a select box with a list of username's taking from a database using PHP enclosed in a form and am using this funciton in the onSubmit to open a new window when the form is submitted.

It works ok in firefox but not IE

_Aerospace_Eng_
10-16-2006, 12:46 AM
I have a feeling it might be your variable names. It could be reserved or something. Try this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>
<script type="text/javascript">
function sendpm()
{
var ftoindex = window.document.pm.fto.selectedIndex;
var ftoindexi = window.document.pm.fto.options[ftoindex].value;
var loc = "newpm.php?fto=" + ftoindexi;
window.open(loc,"pm","height=340,width=629");
return false;
}
</script>
</head>

<body>
<form name="pm" onsubmit="return sendpm()">
<select name="fto">
<option value="123" selected="selected">123</option>
<option value="456">456</option>
</select><input type="submit" value="Submit">
</form>
</body>
</html>

Clive91
10-16-2006, 12:53 AM
In IE it is still opening

newpm.php?fto=

rather than

newpm.php?fto=username

_Aerospace_Eng_
10-16-2006, 02:32 AM
Try

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>
<script type="text/javascript">
function sendpm()
{
var theform = document.forms['pm'].fto.options;
var ftoindex = theform.selectedIndex;
var ftoindexi = theform[ftoindex].value;
var loc = "newpm.php?fto=" + ftoindexi;
window.open(loc,"pm","height=340,width=629");
return false;
}
</script>
</head>

<body>
<form name="pm" onsubmit="return sendpm()">
<select name="fto">
<option value="123" selected="selected">123</option>
<option value="456">456</option>
</select><input type="submit" value="Submit">
</form>
</body>
</html>

Clive91
10-16-2006, 02:35 AM
Still the same.

Works in firefox but not IE

_Aerospace_Eng_
10-16-2006, 02:36 AM
Are you sure there is even a selected value? The first value shown is just shown it doesn't mean its selected. You need to actually set a default value using selected="selected".



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum