PDA

View Full Version : opening a new browser window by choosing a value from a drop down menu


pinkcat_02
02-10-2003, 10:12 PM
Hi I wanna have a drop down menu where a user chooses an option and this value will open a new window browser. I have tried to write the code:

<FORM NAME="form1">
<p>Please choose a branch:
<SELECT NAME="select" ONCHANGE="goto(this.form)" SIZE="1">
<OPTION VALUE="">-------Choose a Selection-------

<option value= onMouseOver="MM_openBrWindow('a.asp','','width=100,height=100')"> Bristol</option>
</form>

but it gave errors. I am not too sure if that's the way of doing it. any ideas of any other ways of doing it ?

Thanks...

A1ien51
02-10-2003, 10:27 PM
well for one thing you have no value----that is a problem....second um mouseover??

Your script has two many things in it.....you have onchange and onmouseover,,,,and I am sure onmouseover does not work in an option tag....

pinkcat_02
02-10-2003, 10:34 PM
<Script Language="JavaScript">
function goto(form) { var index=form.select.selectedIndex
if (form.select.options[index].value != "0") {
location=form.select.options[index].value;}}//--> </SCRIPT>

<SELECT NAME="select" ONCHANGE="goto(this.form)" SIZE="1">
<OPTION VALUE="">-------Choose a Selection-------
<option value= "MM_openBrWindow('a.asp','','width=100,height=100')"> Bristol</option>
</form>


i have tried this as it was logical to take out this mouseover bit.but still there is something wrong with it that i have no clue :(

glenngv
02-11-2003, 03:59 AM
<script language="JavaScript">
function goto(objSel) {
if (objSel.selectedIndex > 0) {
win = window.open(objSel.options[objSel.selectedIndex].value ,'','width=100,height=100');
win.focus();
}
}
//-->
</script>

...
<form>
<select name="select" onchange="goto(this)" size="1">
<option value="">-------Choose a Selection-------</option>
<option value="a.asp">Bristol</option>
...
</select>
</form>

pinkcat_02
02-11-2003, 02:31 PM
Thank you so much, that was a great help :thumbsup:

top500
02-14-2003, 11:11 AM
Now, how to apply the above to this:

<script language="JavaScript" type="text/javascript">
//<![CDATA[
<!--
function startSearch()
{searchString = document.searchForm.searchText.value;
if(searchString != ""){searchEngine = document.searchForm.whichEngine.selectedIndex + 1;finalSearchString = "";
if(searchEngine == 1){finalSearchString = "http://yourUrlgoeshere.com";}
if(searchEngine == 2){finalSearchString = "http://www.aesop.com/cgi-bin/search/search.cgi?q=" + searchString;}location.href = finalSearchString;}}// -->
//]]>
</script>

I would've thunkd it had to do with simply making
location.href into
new.location.href

, but according to this:

Correct - use dependant upon situation
window.location.href
location.href (same as above)
self.location.href (same as above)
top.location.href
parent.location.href
windowName.location.href
etc... another window needs to be specified,

Ok, so since location is a sub-object to window, how do I specify another window, err, how do I do this?

A1ien51
02-14-2003, 04:55 PM
location.href = finalSearchString;
should be

NewWin = window.open(finalSearchString);

top500
02-15-2003, 01:23 AM
tyvm :-)