dies(Auswahl nach dem Formularabsenden wiederherstellen) musst du wohl serverseitig(z.B. in PHP) lösen, und zwar (Beispiel (öffnet im neuen Fenster)):
radiobutton_click_funktionen.js (optional - Funktion "Formular abschicken" wird allen RadioButtons automatisch verpasst):
var isNav = (navigator.appName.indexOf("Netscape") != -1);
var isIE = (navigator.appName.indexOf("Microsoft") != -1);
function linkClickHandler(e)
{
if (!e) var e = window.event;
if (isNav)
{
if (e.target.name)
{
alert(e.target.href);
}
}
if (isIE)
{
if (e.srcElement && e.srcElement.name)
{
alert(e.srcElement.href);
}
}
return false;
}
function radioButtonClickHandler(e)
{
document.forms[0].submit();
}
function addLinkClickHandlers(o)
{
o.onclick = linkClickHandler;
}
function addRadioButtonClickHandlers(o)
{
o.onclick = radioButtonClickHandler;
}
/* Allen Links einen Handler(hier: clickHandler) verpassen */
/*function setLinkActions()
{
for(var i = 0; i < document.links.length; i++)
{
addLinkClickHandlers(document.links[i]);
}
}*/
/* Allen RadioButtons die OnClick-Action document.forms[0].submit() verpassen */
function setRadioButtonActions()
{
for(var i=0; i
{
if(document.forms[0].elements[i].type == "radio")
{
addRadioButtonClickHandlers(document.forms[0].elements[i]);
}
}
}
skript.php:
<html>
<head>
<script language="JavaScript" src="radiobutton_click_funktionen.js"></script>
</head>
<body onLoad="setRadioButtonActions();">
<form action="skript.php" method="post">
<!-- alt (ohne JavaScript): <input type="radio" name="option1" value="wert1 1" onClick="document.forms[0].submit();"> //-->
<table>
<tr>
<td>
<fieldset>
<legend><b>Option 1</b></legend>
<table>
<tr>
<td><input type="radio" name="option1" value="Wert 1 1" <?php if($_POST["option1"] == "Wert 1 1") echo checked; ?>> Wert 1 1</td>
</tr>
<tr>
<td><input type="radio" name="option1" value="Wert 1 2" <?php if($_POST["option1"] == "Wert 1 2") echo checked; ?>> Wert 1 2</td>
</tr>
<tr>
<td><input type="radio" name="option1" value="Wert 1 3" <?php if($_POST["option1"] == "Wert 1 3") echo checked; ?>> Wert 1 3</td>
</tr>
</table>
</fieldset>
</td>
</tr>
<tr>
<td>
<fieldset>
<legend><b>Option 2</b></legend>
<table>
<tr>
<td><input type="radio" name="option2" value="Wert 2 1" <?php if($_POST["option2"] == "Wert 2 1") echo checked; ?>> Wert 2 1</td>
</tr>
<tr>
<td><input type="radio" name="option2" value="Wert 2 2" <?php if($_POST["option2"] == "Wert 2 2") echo checked; ?>> Wert 2 2</td>
</tr>
<tr>
<td><input type="radio" name="option2" value="Wert 2 3" <?php if($_POST["option2"] == "Wert 2 3") echo checked; ?>> Wert 2 3</td>
</tr>
</table>
</fieldset>
</td>
</tr>
<tr>
<td>
<fieldset>
<legend><b>Option 3</b></legend>
<table>
<tr>
<td><input type="radio" name="option3" value="Wert 3 1" <?php if($_POST["option3"] == "Wert 3 1") echo checked; ?>> Wert 3 1</td>
</tr>
<tr>
<td><input type="radio" name="option3" value="Wert 3 2" <?php if($_POST["option3"] == "Wert 3 2") echo checked; ?>> Wert 3 2</td>
</tr>
<tr>
<td><input type="radio" name="option3" value="Wert 3 3" <?php if($_POST["option3"] == "Wert 3 3") echo checked; ?>> Wert 3 3</td>
</tr>
</table>
</fieldset>
</td>
</tr>
</table>
</form>
</body>
</html>
MfG Murdoch!
geschrieben von Murdoch , 31.01.2004, 14:00 Uhr , 42 mal gelesen