Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URL Jump Menu...

Status
Not open for further replies.

rjonesX

Technical User
Jun 18, 2001
56
US
Im trying to create a special url jump menu. You know, those drop down menus that where you select something and then press "submit" and it takes you to a different site. The only difference is this...

I need to make it so that it pulls information from TWO drop down menus rather than one...

[select name=firstpartofurl]
[option value=russ]Russ[/option]
[option value=scott]Scott[/option]
[/select]

[select name=secondpartofurl]
[option value=jones.html]Jones[/option]
[option value=smith.html]Smith[/option]
[/select]

So that if you selected Russ and Jones, it would take you to russjones.html

any ideas?

 


try this

function createURL(){

window.location.href = document.forms[0].firstpartofurl.options[this.selectedIndex].value + document.forms[0].secondpartofurl.options[this.selectedIndex].value

}


<input type=&quot;submit&quot; value=&quot;Click to go there&quot; onclick=&quot;createURL()&quot;>
 
First off, thanks so much for your help, I hugely appreciate it.

When I use this method, instead of redirecting me, it kind of uses the &quot;Get&quot; method, or so it seems, only changing the url at the top of the screen...

important.html?firstpartofurl=scott&secondpartofurl=smith.html

here is the code I am using...


<html>
<head>
<title>Untitled Document</title>

<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
<!--
function createURL(){

window.location.href = document.form1.firstpartofurl.options[this.selectedIndex].value + document.form1.secondpartofurl.options[this.selectedIndex].value

}

//-->
</script>
</head>

<body>
<form name=&quot;form1&quot; id=&quot;form1&quot;>
<select name=&quot;firstpartofurl&quot;>
<option value=&quot;russ&quot; selected>Russ</option>
<option value=&quot;scott&quot; selected>Scott</option>
</select>
<select name=&quot;secondpartofurl&quot;>
<option value=&quot;jones.html&quot; selected>Jones</option>
<option value=&quot;smith.html&quot; selected>Smith</option>
</select>
<input type=&quot;submit&quot; value=&quot;Click to go there&quot; onclick=&quot;createURL()&quot;>
</form>

</body>
</html>


thanks a million...

russ
 
strange

try this

var strURL = document.form1.firstpartofurl.options[this.selectedIndex].value + document.form1.secondpartofurl.options[this.selectedIndex].value

window.location.href = strURL
 
first off - my stubby fingers obviously work faster than my brain.

the code should read.

var strURL = document.form1.firstpartofurl.options[document.form1.firstpartofurl.selectedIndex].value + document.form1.secondpartofurl.options[document.form1.secondpartofurl.selectedIndex].value

however - I have tried to run it and it does just add the values as url parameters.

very strange - thats very odd

it needs more exploration

 

Apologies for the quick formatting, but the following will work:

Code:
<html>
<head>
<title>Untitled Document</title>

<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
<!--
function createURL(){

var formObj = document.forms['form1'];
var strURL = formObj.firstpartofurl.options[formObj.firstpartofurl.selectedIndex].value + formObj.secondpartofurl.options[formObj.secondpartofurl.selectedIndex].value;
window.location = strURL;
}

//-->
</script>
</head>

<body>
<form name=&quot;form1&quot;>
  <select name=&quot;firstpartofurl&quot;>
    <option value=&quot;russ&quot; selected>Russ</option>
    <option value=&quot;scott&quot;>Scott</option>
  </select>
  <select name=&quot;secondpartofurl&quot;>
    <option value=&quot;jones.html&quot; selected>Jones</option>
    <option value=&quot;smith.html&quot;>Smith</option>
  </select>
<input type=&quot;button&quot; value=&quot;Click to go there&quot; onclick=&quot;createURL();&quot;>
</form>

</body>
</html>

Your problem was using a submit button instead of a regular button.

Hope this helps!

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top