Click to See Complete Forum and Search --> : what is wrong with the piece of code?


html20009876
04-14-2005, 12:46 AM
<html>
<head>
<script type="text/javascript">
var mySel;
function getMultiple(ob)
{
if (ob.selectedIndex != -1)
{
mySel=ob.options[ob.selectedIndex].value;
}
}
function DispPage()
{
confirm(mySel);
location.href=mySel.toString()
}
</script>
</head>
<body>

<form name='frmSelect'>
<select name='numbers' multiple='multiple' onblur='getMultiple(document.frmSelect.numbers);'>
<option value="http://www.sun.com/index.html">Index</option>
<option value="http://www.sun.com/download/index.jsp">Downloads</option>
</select>
<input type='submit' value='Go' onclick=DispPage();>
</form>
</body>
</html>

======================================
I hope users can go to selected sun's web-page (as new window) when they press button go .

could u help me to find errors?

thanks

Gautham_2003b
04-14-2005, 02:14 AM
I have few doubts, let me clarify.

First, do you want to have multiple select or single select?
If multiple select, do you want the selected (index and download) pages to open in new windows?

Gautham_2003b
04-14-2005, 02:25 AM
<html>
<head>
<script type="text/javascript">
var mySel;

function DispPage()
{


if(frmSelect.numbers.value=='index')
window.location="http://www.sun.com/index.html";
if(frmSelect.numbers.value=="download")
window.location="http://www.sun.com/download/index.jsp";
}
</script>
</head>
<body>

<form name="frmSelect">
<select name="numbers">
<option value="index" selected>Index</option>
<option value="download">Downloads</option>
</select>
<input type='button' value='Go' onclick="DispPage()">
</form>
</body>
</html>

html20009876
04-14-2005, 03:38 AM
hi 2003,
thanks.
ur code works well.
i need one more solution:
i hope selected web-page pops up in a new window, similar to html TAG:
target="_new"

do u know how to do it?

rhsunderground
04-14-2005, 04:32 PM
try instead of window.location...

window.open("page.html")