Javascrip mit Checkbox und Radio Button
    
Loren
    
    
      
    
  - javascript
- 0 Manyak Online
- 0 peterS.
 nicht angemeldet
 nicht angemeldetHallo,
ich habe eine Frage bitte.
ich habe 2 Radio Buttons (Check all und Clear All).
Wenn ich auf Check All klicke (Radio Button = True),
dann sollen alle Checkbox, die unten angezeigt sind einen Haken setzen !
Und wenn ich wieder auf Clear All (Radio Button = True) klicke, dann werden die
Checkbox unten wieder den Haken entfernen ! Es sind vielleicht 4-5 Checkboxes !
Kann jemand mir da helfen ?
Vielen Dank,
Gruss,
Loren
http://www.teamone.de/selfhtml/tche.htm#a2
Nimm lieber eine Checkbox "Alle" statt zweier Radiobuttons
Wenn man auf "Alle" klickt wird
function AllElements(Formular) {
   für alle Checkboxen im Formular
   document.Formular.CheckboxElement.click()
}
ausgeführt
Checkbox "Alle": onclick="AllElements(this.form)"
gruss Loren;
das waere eine der moeglichen loesungen:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>checkOrClear</title>
<script language="JavaScript" type="text/javascript">
<!--
function checkOrClear(falseOrTrue)
 {for (var i=1;i<=5;i++)
  {self.document.forms["yourForm"].elements["yourCheckBox"+i].checked = falseOrTrue;top.focus();}
 }
//-->
</script>
</head>
<body>
<table cols="1" rows="1" width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
 <td align="center" valign="middle">
 <form name="yourForm">
<table cols="1" rows="1" width="50" cellspacing="0" cellpadding="0" border="0">
 <tr>
  <td align="left" valign="top">
  <nobr>
  <input type="checkbox" name="yourCheckBox1" onclick="top.focus()">wunsch 01<br>
  <input type="checkbox" name="yourCheckBox2" onclick="top.focus()">wunsch 02<br>
  <input type="checkbox" name="yourCheckBox3" onclick="top.focus()">wunsch 03<br>
  <input type="checkbox" name="yourCheckBox4" onclick="top.focus()">wunsch 04<br>
  <input type="checkbox" name="yourCheckBox5" onclick="top.focus()">wunsch 05<br>
  <br>
  <input type="radio" name="yourRadio" onclick="top.checkOrClear(true)">check all<br>
  <input type="radio" name="yourRadio" onclick="top.checkOrClear(false)">clear all<br>
  </nobr>
  </td>
 </tr>
 </table>
</form>
 </td>
</tr>
</table>
</body>
</html>
viel spass und by(t)e by(t)e - peterS. - pseliger@gmx.net