JavaScript radio Buttons und Auswahlliste
Charli
- javascript
Hallo zusammen,
ich habe folgendes Problem und brauche Hilfe:
Ich habe eine Funktion "optNumbering" programmiert der beim Klicken von radio Buttons die Auswahllisten dementsprechend aktualiseren soll aber es funktioniert nicht.
Klick: radioButton = 0
docForms.cmbeineVorspalte.selectedIndex = 1;
docForms.cmbzweiVorspalten.selectedIndex = 1;
docForms.cmbVorjahrVorspalte.selectedIndex = 1;
Klick: radioButton = 1
docForms.cmbeineVorspalte.selectedIndex = 1;
docForms.cmbzweiVorspalten.selectedIndex = 2;
docForms.cmbVorjahrVorspalte.selectedIndex = 1;
Klick: radioButton = 2
docForms.cmbeineVorspalte.selectedIndex = 2;
docForms.cmbzweiVorspalten.selectedIndex = 3;
docForms.cmbVorjahrVorspalte.selectedIndex = 2;
<html>
<head>
<script language="javascript">
function optNumbering(){
var docForms = document.forms[0];
switch (CVactFormatLevel){
case 0:
docForms.cmbeineVorspalte.selectedIndex = 1;
docForms.cmbzweiVorspalten.selectedIndex = 1;
docForms.cmbVorjahrVorspalte.selectedIndex = 1;
break;
case 1:
docForms.cmbeineVorspalte.selectedIndex = 1;
docForms.cmbzweiVorspalten.selectedIndex = 2;
docForms.cmbVorjahrVorspalte.selectedIndex = 1;
break;
case 2:
docForms.cmbeineVorspalte.selectedIndex = 2;
docForms.cmbzweiVorspalten.selectedIndex = 3;
docForms.cmbVorjahrVorspalte.selectedIndex = 2;
break;
default:
break;
}
}
}
</script>
</head>
<body>
<form action="" name="ARtableProperties">
<div class="main">
<div class="content">
<!--Begin Table Content-->
<table class="tableContent" cellspacing="0" name="tableContent" id="tableContent">
<tbody>
<tr>
<td>
<fieldset>
<legend>Nummerierung</legend>
<table cellspacing="0" style="margin-top: 5px;" width="100%">
<tbody>
<tr>
<td>
<input type="radio" name="optNummerierung" value="0" onChange="optNumbering()"> A,B,C, ...<br />
<input type="radio" name="optNummerierung" value="1" onChange="optNumbering()"> |,||,|||, ...<br />
<input type="radio" name="optNummerierung" value="2" onChange="optNumbering()"> 1,2,3, ...<br />
</td>
</tr>
</tbody>
</table>
</fieldset>
</td>
</tr>
<tr>
<td colspan="2">
<fieldset>
<legend>Ausrichtung aktuelles Jahr</legend>
<table cellspacing="0" style="margin-top: 5px;" width="100%">
<tbody>
<tr>
<td width="40%">mit einer Vorspalte:</td>
<td><select name="cmbeineVorspalte" title="">
<option value=''>Bitte auswählen...</option>
<option value="1">Hauptspalte</option>
<option value="2">1. Vorspalte</option>
</select>
</td>
</tr>
<tr>
<td width="40%">mit zwei Vorspalten:</td>
<td><select name="cmbzweiVorspalten" title="">
<option value=''>Bitte auswählen...</option>
<option value="1">Hauptspalte</option>
<option value="2">1. Vorspalte</option>
<option value="3">2. Vorspalte</option>
</select>
</td>
</tr>
</tbody>
</table>
</fieldset>
</td>
</tr>
<tr>
<td colspan="2">
<fieldset>
<legend>Ausrichtung Vorjahr</legend>
<table cellspacing="0" style="margin-top: 5px;" width="100%">
<tbody>
<tr>
<td width="40%">mit einer Vorspalte:</td>
<td><select name="cmbVorjahrVorspalte" title="">
<option value=''>Bitte auswählen...</option>
<option value="1">Hauptspalte</option>
<option value="2">1. Vorspalte</option>
</select>
</td>
</tr>
</tbody>
</table>
</fieldset>
</td>
</tr>
</tbody>
</table>
<!--End Table Content-->
</div>
</div>
</form>
</body>
</html>
onclick="optNumbering(this)"
==> übergib der Funktion das Radio-Object, oder das value!
<script type="text/javascript">
function optNumbering(obj) {
var docForms = document.forms[0];
switch(obj.value){
case 0:
docForms.cmbeineVorspalte.selectedIndex = 1;
docForms.cmbzweiVorspalten.selectedIndex = 1;
docForms.cmbVorjahrVorspalte.selectedIndex = 1;
break;
case 1:
docForms.cmbeineVorspalte.selectedIndex = 1;
docForms.cmbzweiVorspalten.selectedIndex = 2;
docForms.cmbVorjahrVorspalte.selectedIndex = 1;
break;
case 2:
docForms.cmbeineVorspalte.selectedIndex = 2;
docForms.cmbzweiVorspalten.selectedIndex = 3;
docForms.cmbVorjahrVorspalte.selectedIndex = 2;
break;
default:
break;
}
}
</script>
Klappt noch nicht ganz, die Auswahl findet nicht statt!
Sollte dir bisschen weiterhelfen!