문제

i want to have a simple dropdown to choose betwenn 5 links (pages) but i want the link-page to be opened in the same window (target _self) after klicking "send". it should be as simple as possible. this is what i have so far:

<form>
<select id="setit" style="color: #0000FF" size="1" name="test">
<option value="#">please choose</option>
<option value="http://www.altavista.com">AltaVista</option>
<option value="http://www.yahoo.com">Yahoo</option>
 <option value="http://www.google.com">Google</option></select>
 <input type="button" value="send"
onclick="window.open(setit.options[setit.selectedIndex].value)">
</form>

is it also possible to have the first one "not clickable" (nothing should happen after clicking on "send" on this one)?

thanks, you're awesome!

도움이 되었습니까?

해결책

Below is my modified code:

<script type="text/javascript">
function openWindow(location){
    if(location == "#")return;
    window.open(location,'_self');
}
</script>
<select id="setit" style="color: #0000FF" size="1" name="test">
<option value="#">please choose</option>
<option value="http://www.altavista.com">AltaVista</option>
<option value="http://www.yahoo.com">Yahoo</option>
<option value="http://www.google.com">Google</option></select>
<input type="button" value="send" target="_self"
onclick="openWindow(setit.options[setit.selectedIndex].value)">
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top