Behöver hjälp med en window.open-funktion.
Hejsan skulle behöva hjälp med en window.open-funktion.
Finns det något sätt att skriva så när man gör sitt val i den andra dropdownlistan och sedan klickar på knappen så öppnas länken i samma fönster. Just nu öppnas ett nytt fönster för varje klick.
Går detta att lösa?
Tacksam för svar...
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Electronic Wiring Diagram, EWD</title>
<script type="text/javascript" src="pdf-links.js">
</script>
</head>
<body bgcolor="#ffffff">
<form name="myform"><div align="center">
<select name="optone" size="1"
onchange="setOptions(document.myform.optone.options
[document.myform.optone.selectedIndex].value);">
<option value=" " selected="selected"> </option>
<option value="1">C30</option>
<option value="2">V40</option>
<option value="3">V50</option>
</select><br> <br>
<select name="opttwo" size="1">
<option value=" " selected="selected">Välj bilmodell först</option>
</select>
<input type="button" name="go" value="Öppna bok"
onclick="window.open(document.myform.opttwo.options
[document.myform.opttwo.selectedIndex].value);">
</div></form>
</body>
</html>
Javascriptet
function setOptions(chosen) {
var selbox = document.myform.opttwo;
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] = new Option('Vaelj bilmodell',' ');
}
if (chosen == "1") {
selbox.options[selbox.options.length] = new Option('39103012 C30 2007','39103012/index_39103012.html');
selbox.options[selbox.options.length] = new Option('39114012 C30 200X','39114012/index_39114012.html');
selbox.options[selbox.options.length] = new Option('39126012 C30 200X','39126012/index_39126012.html');
}
if (chosen == "2") {
selbox.options[selbox.options.length] = new Option('second choice - option one','twoone');
selbox.options[selbox.options.length] = new Option('second choice - option two','twotwo');
}
if (chosen == "3") {
selbox.options[selbox.options.length] = new Option('third choice - option one','threeone');
selbox.options[selbox.options.length] = new Option('third choice - option two','threetwo');
}
}