Select-Aufzählungen an Button als Link anknüpfen (in JavaScript)
Ich möchte in JavaScript-Dokument den Select-Aufzählungen Hyperlink so anknüpfen, dass ich die Möglichkeit habe, ausgewählte Select-Aufzählung per Button-Klick anzufordern
Habe es nicht geschafft, weil JavaScript Kenntnisse von mir sowas wie Niveau noch nicht haben.
Für's Helfen danke ich Euch allen ganz herzlich!!!
Einfach kopieren in .txt File und als html umtaufen. Dann sollte alles selbstverständlich sein, wie ich es gemeint habe.
<html>
<head>
<title> Allgemeine Begriffe </title>
<script type="text/javascript">
function lade(form)
{
var one, choice;
choice=form.modus.selectedIndex;
if(choice==0)
{
one = a href="test.txt" style="text-decoration:none" target="_blank";
}
else
{
one= a href="test.txt" style="text-decoration:none" target="_blank";
}
else
{
one= a href="test.txt" style="text-decoration:none" target="_blank";
}
}
</script>
</head>
<body>
<div align="center">
<h1> Allgemeine Begriffe</h1>
<form name="form1">
<select name="modus">
<option selected> Dokument 1 anfordern</option>
<option>Dokument 2 anfordern</option>
<option>Dokument 3 anfordern</option>
</select>
<input type="button" value="Anfordern" onClick="lade(this.form)">
</form>
</div>
</body>
</html>
Für's Helfen danke ich Euch allen ganz herzlich!!!
Einfach kopieren in .txt File und als html umtaufen. Dann sollte alles selbstverständlich sein, wie ich es gemeint habe.
<html>
<head>
<title> Allgemeine Begriffe </title>
<script type="text/javascript">
function lade(form)
{
var one, choice;
choice=form.modus.selectedIndex;
if(choice==0)
{
one = a href="test.txt" style="text-decoration:none" target="_blank";
}
else
{
one= a href="test.txt" style="text-decoration:none" target="_blank";
}
else
{
one= a href="test.txt" style="text-decoration:none" target="_blank";
}
}
</script>
</head>
<body>
<div align="center">
<h1> Allgemeine Begriffe</h1>
<form name="form1">
<select name="modus">
<option selected> Dokument 1 anfordern</option>
<option>Dokument 2 anfordern</option>
<option>Dokument 3 anfordern</option>
</select>
<input type="button" value="Anfordern" onClick="lade(this.form)">
</form>
</div>
</body>
</html>
Please also mark the comments that contributed to the solution of the article
Content-Key: 138340
Url: https://administrator.de/contentid/138340
Printed on: April 18, 2024 at 05:04 o'clock
1 Comment
<script type="text/javascript">
function $(sId) { return document.getElementById(sId); }
</script>
<!-- ... -->
<select name="modus" onChange="$('link').href = this.value;">
<option selected="selected" value="text1.txt">Dokument 1</option>
<option value="text2.txt">Dokument 2</option>
<option value="text3.txt">Dokument 3</option>
</select>
<a id="link" href="text1.txt" style="text-decoration:none" target="_blank">download</a>
http://de.selfhtml.org/javascript/objekte/index.htm