FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Option Redirect

 


DanielXP
Im trying to make a option redirect but i can't get it to work


this is my code

Code:
<SCRIPT LANGUAGE="JavaScript">
<!--
function redirect(url){
window.location="+url+";
}
// -->
</script>


and this

Code:
<select name='select'>
<option onclick=\"redirect('http://www.google.co.uk'); return true\">Points</option>
<option onclick=\"redirect('http://www.google.co.uk'); return true\">VIP</option>
<option onclick=\"redirect('http://www.google.co.uk'); return true\">Bank</option>
<option onclick=\"redirect('http://www.google.co.uk'); return true\">Lottery</option>
<option onclick=\"redirect('http://www.google.co.uk'); return true\">Bold Username</option>
</select>


Its has the \ before the " because its in a echo.
kevinalle
I think the code should be:
Code:
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
<!--
function redirect(url){
window.location.href=url;
}
// -->
</script>


Note: I removed the "" from url and added the .href.
This should work.
Try it!
rohan2kool
why are you escaping the quotes in <select><option>??
DanielXP
rohan2kool wrote:
why are you escaping the quotes in <select><option>??


Me no understand
DanielXP
kevinalle wrote:
I think the code should be:
Code:
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
<!--
function redirect(url){
window.location.href=url;
}
// -->
</script>


Note: I removed the "" from url and added the .href.
This should work.
Try it!


Tryed it!

Nope don't work Sad

I think its some thing to do with the selection
rohan2kool
DanielXP wrote:
rohan2kool wrote:
why are you escaping the quotes in <select><option>??


Me no understand


oops.. didn't read ur last line:

Quote:

Its has the \ before the " because its in a echo.


my bad.. sorry Very Happy
DanielXP
I think its something about the selection

not the java

and ok read need time! Razz
kevinalle
This should be your code...

Code:
<form name="form1">
<select name="select1" OnChange="location.href=form1.select1.options[selectedIndex].value">
     <option selected>Please Select...
     <option value="http://url/">option1</option>
     <option value="http://url/">option2</option>
     <option value="http://url/">option3</option>
</select>
</form>


OK?
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.