Hallo DerBlaueBaum,
vielen Dank das dir die Sache angesehen hast.
Was ist der Vorteil die Checkboxen über ein Formular auszugeben?
Ansonsten sollte der Code ja auch funktionieren wenn ich Ihn auf meine ID´s umschreiben oder ?
Ich setz hier mal den bisher gesamten Code rein:
Damit lässt es sich wohl auch besser nachvollziehen.
Im Prinzip soll zum Schluss folgendes passieren (das ganze ist für ein Spiel gedacht)
Der Nutzer gibt bei "Goldeinsatz" an wieviel Gold er für seine Bankettwaren ausgeben will.
Danach wählt er über die Checkboxen aus welche er kaufen möchte.
Dann gibt er unter "Preise / Mittelwerte" die "Max" und "Min" Werte ein.
Zum Schluss wird unter "Ehre" ausgegeben wieviel Ehre er für sein Gold theoretisch bekommen würde.
Java:In die Zwischenablage kopieren
<html>
<head>
<script type="text/javascript">
function calc ()
{
if (document.getElementById("cbw").checked == true && document.getElementById("cbm").checked == true && document.getElementById("cbme").checked == true && document.getElementById("cbg").checked == true && document.getElementById("cbwe").checked == true && document.getElementById("cbs").checked == true && document.getElementById("cbge").checked == true && document.getElementById("cbse").checked == true ) {
var goldi =document.getElementById("goldeinsatz").value;
var ehreeingabe = goldi/8;
document.getElementById("ehre").value=ehreeingabe;
}
</script>
</head>
<body>
<table width="650" align="center" border="1" style="background-color:#FFFFCC">
<tr align="center">
<td>Goldeinsatz</td>
</tr>
<tr align="center">
<td><input id="goldeinsatz" style="text-align: center;" type="text" name="name" size="5"></td>
</tr>
<tr align="center">
<td>Steuer in %</td>
</tr>
<tr align="center">
<td><input id="steuer" style="text-align: center;" type="text" name="name" size="2" value="25" readonly="readonly" ></td>
</tr>
</table><table width="650" align="center" border="1" style="background-color:#FFFFCC">
<tr align="center">
<td>möchte ich kaufen</td>
</tr>
</table>
<table width="650" align="center" border="1" style="background-color:#FFFFCC">
<tr align="center">
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/e/e3/Venison.png/50px-Venison.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/3/30/Furiture.png/50px-Furiture.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/3/3e/Metalware.png/50px-Metalware.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/2/28/Clothing.png/50px-Clothing.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/6/69/Wine.png/50px-Wine.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/7/77/Salt.png/50px-Salt.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/9/97/Spice.png/50px-Spice.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/8/83/Silk.png/50px-Silk.png"></td>
</tr>
<tr align="center">
<td><input type="checkbox" id="cbw"></td>
<td><input type="checkbox" id="cbm"></td>
<td><input type="checkbox" id="cbme"></td>
<td><input type="checkbox" id="cbg"></td>
<td><input type="checkbox" id="cbwe"></td>
<td><input type="checkbox" id="cbs"></td>
<td><input type="checkbox" id="cbge"></td>
<td><input type="checkbox" id="cbse"></td>
</tr>
</table>
<table width="650" align="center" border="1" style="background-color:#FFFFCC">
<tr align="center">
<td>Pakete</td>
</tr>
</table>
<table width="650" align="center" border="1" style="background-color:#FFFFCC">
<tr align="center">
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/e/e3/Venison.png/50px-Venison.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/3/30/Furiture.png/50px-Furiture.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/3/3e/Metalware.png/50px-Metalware.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/2/28/Clothing.png/50px-Clothing.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/6/69/Wine.png/50px-Wine.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/7/77/Salt.png/50px-Salt.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/9/97/Spice.png/50px-Spice.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/8/83/Silk.png/50px-Silk.png"></td>
</tr>
<tr align="center">
<td><input style="text-align: center;" type="text" name="name" size="1" value="50" readonly="readonly"></td>
<td><input style="text-align: center;" type="text" name="name" size="1" value="50" readonly="readonly"></td>
<td><input style="text-align: center;" type="text" name="name" size="1" value="50" readonly="readonly"></td>
<td><input style="text-align: center;" type="text" name="name" size="1" value="50" readonly="readonly"></td>
<td><input style="text-align: center;" type="text" name="name" size="1" value="20" readonly="readonly"></td>
<td><input style="text-align: center;" type="text" name="name" size="1" value="20" readonly="readonly"></td>
<td><input style="text-align: center;" type="text" name="name" size="1" value="20" readonly="readonly"></td>
<td><input style="text-align: center;" type="text" name="name" size="1" value="20" readonly="readonly"></td>
</tr>
</table>
<table width="650" align="center" border="1" style="background-color:#FFFFCC">
<tr align="center">
<td>Preise / Mittelwert</td>
</table>
<table width="650" align="center" border="1" style="background-color:#FFFFCC">
<tr align="center">
<td style="background-color:#eaf4fe" style="text-align: center;">Max</td>
<td style="background-color:#eaf4fe" style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/e/e3/Venison.png/50px-Venison.png"></td>
<td style="background-color:#eaf4fe" style="text-align: center;">Min</td>
<td style="background-color:#ffddb7" style="text-align: center;">Max</td>
<td style="background-color:#ffddb7" style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/3/30/Furiture.png/50px-Furiture.png"></td>
<td style="background-color:#ffddb7" style="text-align: center;">Min</td>
<td style="background-color:#eaf4fe" style="text-align: center;">Max</td>
<td style="background-color:#eaf4fe" style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/3/3e/Metalware.png/50px-Metalware.png"></td>
<td style="background-color:#eaf4fe" style="text-align: center;">Min</td>
<td style="background-color:#ffddb7" style="text-align: center;">Max</td>
<td style="background-color:#ffddb7" style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/2/28/Clothing.png/50px-Clothing.png"></td>
<td style="background-color:#ffddb7" style="text-align: center;">Min</td>
</tr>
<tr align="center">
<td style="background-color:#eaf4fe"><input id="wildmax" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#eaf4fe"><input id="wildmiddle" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#eaf4fe"><input id="wildmin" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#ffddb7"><input id="moebelmax" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#ffddb7"><input id="moebelmiddle" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#ffddb7"><input id="moebelmin" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#eaf4fe"><input id="metallmax" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#eaf4fe"><input id="metallmiddle" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#eaf4fe"><input id="metallmin" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#ffddb7"><input id="gewaendermax"style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#ffddb7"><input id="gewaendermiddle" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#ffddb7"><input id="gewaendermin" style="text-align: center;" type="text" name="name" size="1"></td>
</tr>
<tr align="center">
<td style="background-color:#ffddb7" style="text-align: center;">Max</td>
<td style="background-color:#ffddb7" style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/6/69/Wine.png/50px-Wine.png"></td>
<td style="background-color:#ffddb7" style="text-align: center;">Min</td>
<td style="background-color:#eaf4fe" style="text-align: center;">Max</td>
<td style="background-color:#eaf4fe" style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/7/77/Salt.png/50px-Salt.png"></td>
<td style="background-color:#eaf4fe" style="text-align: center;">Min</td>
<td style="background-color:#ffddb7" style="text-align: center;">Max</td>
<td style="background-color:#ffddb7" style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/9/97/Spice.png/50px-Spice.png"></td>
<td style="background-color:#ffddb7" style="text-align: center;">Min</td>
<td style="background-color:#eaf4fe" style="text-align: center;">Max</td>
<td style="background-color:#eaf4fe" style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/8/83/Silk.png/50px-Silk.png"></td>
<td style="background-color:#eaf4fe" style="text-align: center;">Min</td>
</tr>
<tr align="center">
<td style="background-color:#ffddb7"><input id="weinmax" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#ffddb7"><input id="weinmiddle" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#ffddb7"><input id="weinmin" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#eaf4fe"><input id="salzmax" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#eaf4fe"><input id="salzmiddle" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#eaf4fe"><input id="salzmin" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#ffddb7"><input id="gewuerzemax" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#ffddb7"><input id="gewuerzemiddle" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#ffddb7"><input id="gewuerzemin" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#eaf4fe"><input id="seidemax"style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#eaf4fe"><input id="seidemiddle" style="text-align: center;" type="text" name="name" size="1"></td>
<td style="background-color:#eaf4fe"><input id="seidemin" style="text-align: center;" type="text" name="name" size="1"></td>
</tr>
</table>
<table width="650" align="center" border="1" style="background-color:#FFFFCC">
<tr align="center">
<td>zu kaufende Menge</td>
</tr>
</table>
<table width="650" align="center" border="1" style="background-color:#FFFFCC">
<tr align="center">
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/e/e3/Venison.png/50px-Venison.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/3/30/Furiture.png/50px-Furiture.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/3/3e/Metalware.png/50px-Metalware.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/2/28/Clothing.png/50px-Clothing.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/6/69/Wine.png/50px-Wine.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/7/77/Salt.png/50px-Salt.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/9/97/Spice.png/50px-Spice.png"></td>
<td style="text-align: center;"><img src="http://hilfe.strongholdkingdoms.de/images/thumb/8/83/Silk.png/50px-Silk.png"></td>
</tr>
<tr align="center">
<td><input style="text-align: center;" type="text" name="name" size="1"></td>
<td><input style="text-align: center;" type="text" name="name" size="1"></td>
<td><input style="text-align: center;" type="text" name="name" size="1"></td>
<td><input style="text-align: center;" type="text" name="name" size="1"></td>
<td><input style="text-align: center;" type="text" name="name" size="1"></td>
<td><input style="text-align: center;" type="text" name="name" size="1"></td>
<td><input style="text-align: center;" type="text" name="name" size="1"></td>
<td><input style="text-align: center;" type="text" name="name" size="1"></td>
</tr>
</table>
<table width="650" align="center" border="1" style="background-color:#FFFFCC">
<tr align="center">
<td colspan="12">Ehre</td>
</tr>
<tr align="center">
<td colspan="12"><input id="ehre" align="middle" style="text-align: center;" type="text" name="name" size="10"></td>
</tr>
</table>
<table align="center" >
<tr>
<td><input type="button" name="Name" value="Ehre berechnen" onClick="calc ()"/></td>
<td> <input type="reset" name="Name" value="Alles Zurücksetzen"/></td>
</tr>
</table>
</body>
</html>