option tag

rumchi

Registered
Имам

<select>
<option>Изберете сървър</option>
<option>Classic #1</option>
<option>Classic #2</option>
<option>Zombie #3</option>
</select>

Как да направя когато избера например Classic #1 да ме праща на пределена страница, ако избера Classic #2 да ме праща на друга и т.н. ?
Преди го гледах някъде, но не мога да го намеря как ставаше този номер.
 
Така?
Това в хед таговете
<script type="text/javascript">function otidi(forma) {
var index=forma.select.selectedIndex
if (forma.select.options[index].value.length != 0) {
location.replace(forma.select.options[index].value);
}
} </script>
Това в боди:
<form name="forma">
<select name="select" class="fatbuttom">
<option onclick="otidi(forma)" value="http://link.bg">Otidi</option>
</select>
</form>
 
Код:
<head>
<script LANGUAGE="JavaScript">

</script>
</head>
<form name="form">
<div align="left"><p><select name="site" size="1"
style="font-family: Verdana; font-size: 10pt; margin-bottom: 0px">
<option value="http://www.yourlink.com">Your Text</option>
<option
value="http://www.yourlink.com">Your Text</option>
<option
value="http://www.yourlink.com">Your Text</option>
<option
value="http://www.yourlink.com">Your Text</option>
<option
value="http://www.yourlink.com">Your Text</option>
</select>  <input type="button" value="Go!" onClick="javascript:formHandler(this)"
</div>
</form>
:?:
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Untitled Document</title>
<script type="text/javascript">
function redirect(){
var pole = document.getElementById('forma').value;
window.location = pole;
}
</script>
</head>

<body>
<select id="forma" onchange="redirect()">
<option value="">Изберете сървър</option>
<option value="http://data.bg">Classic #1</option>
<option value="http://zamunda.net">Classic #2</option>
<option value="http://web-tourist.net">Zombie #3</option>
</select>
</body>
</html>
 
emagi каза:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Untitled Document</title>
<script type="text/javascript">
function redirect(){
var pole = document.getElementById('forma').value;
window.location = pole;
}
</script>
</head>

<body>
<select id="forma" onchange="redirect()">
<option value="">Изберете сървър</option>
<option value="http://data.bg">Classic #1</option>
<option value="http://zamunda.net">Classic #2</option>
<option value="http://web-tourist.net">Zombie #3</option>
</select>
</body>
</html>


Мерси + 1

@DeathGuard_ кода ти не провървя, но мерси все пак
@federer_11 Не търсех точно това, но мерси все пак
 
rumchi каза:
emagi каза:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Untitled Document</title>
<script type="text/javascript">
function redirect(){
var pole = document.getElementById('forma').value;
window.location = pole;
}
</script>
</head>

<body>
<select id="forma" onchange="redirect()">
<option value="">Изберете сървър</option>
<option value="http://data.bg">Classic #1</option>
<option value="http://zamunda.net">Classic #2</option>
<option value="http://web-tourist.net">Zombie #3</option>
</select>
</body>
</html>


Мерси + 1

@DeathGuard_ кода ти не провървя, но мерси все пак
@federer_11 Не търсех точно това, но мерси все пак
Нп но кода си е верен аз го използвам :)
 

Горе