Ich sah auf einem Link diese Fähigkeit, Kontrollkästchen hinzufügen, aber ich brauche Radio-Buttons sofort mit jeder Art von Codierung möglich hinzugefügt.summieren Werte von Radio-Buttons onclick ohne Formular
http://www.madirish.net/tech.php?section=1&article=7
meine Form ist die folgende:
<form action="orders.php" method="post" name="Reservar" target="_self">
<table width="800" border="0">
<?php
foreach ($rows as $row) {
?>
<tr>
<td><input name="platofuerte" type="radio" onClick="checkTotal()" value="<?php echo $row['Producto_Precio']; ?>" />
</td>
<td><input name="platofuerte1" type="hidden" value="<?php echo $row['Producto_ID']; ?>" /><img src='<?php echo htmlspecialchars($row['Producto_Imagen']); ?>' alt='image' name="imagen" id="imagen" />
</td>
<td width=""><input name="" type="label" value='<?php echo $row['Producto_Nombre']; ?>' />
</td>
<td width=""><input name="" type="label" value='<?php echo $row['Producto_Descripcion']; ?>' />
</td>
<td width=""><input name="price" type="label" value='$<?php echo $row['Producto_Precio']; ?>' />
</td></tr>
</table>
<table width="800" border="0">
<td><input name="bebida" type="radio" onClick="checkTotal()" value="<?php echo $row['Producto_Precio']; ?>" />
</td>
<td><input name="bebida1" type="hidden" value="<?php echo $row['Producto_ID']; ?>" /><img src='<?php echo htmlspecialchars($row['Producto_Imagen']); ?>' alt='image' name="imagen" id="imagen" />
</td>
<td width=""><input name="" type="label" value='<?php echo $row['Producto_Nombre']; ?>' />
</td>
<td width=""><input name="" type="label" value='<?php echo $row['Producto_Descripcion']; ?>' />
</td>
<td width=""><input name="price" type="label" value='$<?php echo $row['Producto_Precio']; ?>' />
</td>
</tr>
<?php
/*}*/
} ?>
</table>
<table width="800" border="0">
<td><input name="postre" type="radio" onClick="checkTotal()" value="<?php echo $row['Producto_Precio']; ?>" />
</td>
<td><input name="postre1" type="hidden" value="<?php echo $row['Producto_ID']; ?>" /><img src='<?php echo htmlspecialchars($row['Producto_Imagen']); ?>' alt='image' name="imagen" id="imagen" />
</td>
<td width=""><input name="" type="label" value='<?php echo $row['Producto_Nombre']; ?>' />
</td>
<td width=""><input name="" type="label" value='<?php echo $row['Producto_Descripcion']; ?>' />
</td>
<td width=""><input name="" type="label" value='$<?php echo $row['Producto_Precio']; ?>' />
</td>
</tr>
</table>
<table width="800" border="0">
<tr>
<td><input name="aperitivo" type="radio" onClick="checkTotal()" value="<?php echo $row['Producto_Precio']; ?>" />
</td>
<td><input name="aperitivo1" type="hidden" value="<?php echo $row['Producto_ID']; ?>" /><img src='<?php echo htmlspecialchars($row['Producto_Imagen']); ?>' alt='image' name="imagen" id="imagen" />
</td>
<td width=""><input name="" type="label" value='<?php echo $row['Producto_Nombre']; ?>' />
</td>
<td width=""><input name="" type="label" value='<?php echo $row['Producto_Descripcion']; ?>' />
</td>
<td width=""><input name="" type="label" value='$<?php echo $row['Producto_Precio']; ?>' />
</td>
</tr>
</table>
<input type="submit" name="Reservar" id="Reservar" value="Reservar" />
</p>
<p> </p>
<p> </p>
<input type="text" size="2" name="total" value="0"/>
</form>
im letzten Texteingabefeld, die Summen der ausgewählten Radio-Buttons erscheinen, in der Theorie. Wie kann ich das machen? Dieser proposed Code ist für eine Gruppe von Radios mit dem gleichen Namen und die Radio-Tasten in benachbarten Zeilen des Textes
meine PHP-Seite führt Abfragen von jedem Gruppennamen von Radio-Buttons, so dass ich am Ende mit bis zu 4 Artikel pro Gruppe. Ich muss die Summe der Radios aus jeder Gruppe addieren.
die vorgeschlagene Skript für Kontrollkästchen ist die folgende:
<script type="text/javascript">
function checkTotal() {
document.listForm.total.value = '';
var sum = 0;
for (i=0;i<document.listForm.choice.length;i++) {
if (document.listForm.choice[i].checked) {
sum = sum + parseInt(document.listForm.choice[i].value);
}
}
document.listForm.total.value = sum;
}
</script>
Ist es möglich, jquery zu verwenden? – Wilmer
Ich bin bereit zu lernen, hat irgendwelche Ideen, welchen Code zu verwenden? eine Probe? –