jeatrexs
Goto Top

Javascript benötige unterstützung

Hallo leute.

ich brauche etwas hilfe bin etwas eingerostet in Javascript... kann mir jemand sagen warum das nicht funktioniert?

Es handelt sich um ein Script:

http://www.jeatrexs.bplaced.net/filemanager/php/gohg/order.php

Wenn man dort z.b. die Anzahl vom Publicserverslots ändert, sollte unten gleich der Preis stehen..

was hab ich falsch gemacht?

Schaut im Sourcecode nach oder hier:

<div align="left">
<form name="best-cs-1" action="order-game-2.php" method="post">
Step 1: Serverinformationen<br />
<br />
<div algin="center">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="35%">Clanserver</td>
<td width="65%">
<select name="clan" onChange="berechne();">
<option value="0" selected="selected">Kein Clanserver</option>
<option value="2">2 Slots</option>
<option value="4">4 Slots</option>
<option value="6">6 Slots</option>
<option value="8">8 Slots</option>
<option value="10">10 Slots</option>
<option value="12">12 Slots</option>
<option value="14">14 Slots</option>
<option value="16">16 Slots</option>
</select> [Slot 0,70]
</td>
</tr>
</table>
<br />
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="35%">Publicserver</td>
<td width="65%">
<select name="public" onChange="berechne();">
<option value="0" selected="selected" >Kein Publicserver</option>
<option value="2">2 Slots</option>
<option value="4">4 Slots</option>
<option value="6">6 Slots</option>
<option value="8">8 Slots</option>
<option value="10">10 Slots</option>
<option value="12">12 Slots</option>
<option value="14">14 Slots</option>
<option value="16">16 Slots</option>
<option value="18">18 Slots</option>
<option value="20">20 Slots</option>
<option value="22">22 Slots</option>
<option value="24">24 Slots</option>
<option value="26">26 Slots</option>
<option value="28">28 Slots</option>
<option value="30">30 Slots</option>
<option value="32">32 Slots</option>
</select> [Slot 1,40]
</td>
</tr>
</table>
<br />
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="35%">Teamspeak² Server</td>
<td width="65%">
<select name="teamspeak" onChange="berechne();">
<option value="0" selected="selected">Kein Teamspeakserver</option>
<option value="2">2 Slots</option>
<option value="4">4 Slots</option>
<option value="6">6 Slots</option>
<option value="8">8 Slots</option>
<option value="10">10 Slots</option>
<option value="12">12 Slots</option>
<option value="14">14 Slots</option>
<option value="16">16 Slots</option>
<option value="18">18 Slots</option>
<option value="20">20 Slots</option>
<option value="22">22 Slots</option>
<option value="24">24 Slots</option>
<option value="26">26 Slots</option>
<option value="28">28 Slots</option>
<option value="30">30 Slots</option>
<option value="32">32 Slots</option>
<option value="34">34 Slots</option>
<option value="36">36 Slots</option>
<option value="38">38 Slots</option>
<option value="40">40 Slots</option>
<option value="42">42 Slots</option>
<option value="44">44 Slots</option>
<option value="46">46 Slots</option>
<option value="48">48 Slots</option>
<option value="50">50 Slots</option>
<option value="52">52 Slots</option>
<option value="54">54 Slots</option>
<option value="56">56 Slots</option>
<option value="58">58 Slots</option>
<option value="60">60 Slots</option>
<option value="62">62 Slots</option>
<option value="64">64 Slots</option>
<option value="66">66 Slots</option>
<option value="68">68 Slots</option>
<option value="70">70 Slots</option>
<option value="72">72 Slots</option>
<option value="74">74 Slots</option>
<option value="76">76 Slots</option>
<option value="78">78 Slots</option>
<option value="80">80 Slots</option>
<option value="82">82 Slots</option>
<option value="84">84 Slots</option>
<option value="86">86 Slots</option>
<option value="88">88 Slots</option>
<option value="90">90 Slots</option>
<option value="92">92 Slots</option>
<option value="94">94 Slots</option>
<option value="96">96 Slots</option>
<option value="98">98 Slots</option>
<option value="100">100 Slots</option>
</select> [Slot 0,20]
</td>
</tr>
</table>
<br />
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>Laufzeit</td>
<td width="65%">
<select name="zeit" onChange="berechne();">
<option value="1">1 Monat [10 Euro Setup]</option>
<option value="3">3 Monate[5 Euro Setup]</option>
<option value="6">6 Monate[0 Euro Setup]</option>
<option value="12">1 Jahr[0 Euro Setup]</option>
<option value="24">2 Jahre[0 Euro Setup]</option>
</select>
</td>
</tr>
</table>
<br />
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="35%">Werbung</td>
<td width="65%">
<select name="werbung" onChange="berechne();">
<option value="0" selected="selected">"by GOHG-Server.de" [- 5 Euro]</option>
<option value="1">Ohne</option>
</select>
</td>
</tr>
</table>
<br />
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%">
<input name="bestell" type="submit" id="bestell" value="Speichern & Weiter">
<input type="reset" name="resetstep1" value="Zurücksetzen" />
</td>
</tr>
</table>
<br />
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="35%">Entstehende Kosten:</td>
<td width="65%">
<script language="javascript">
function berechne(){
var v_clan = document.getElementsByName("clan").value;
var v_public = document.getElementsByName("public").value;
var v_teamspeak = document.getElementsByName("teamspeak").value;
var v_zeit = document.getElementsByName("zeit").value;
var v_werbung = document.getElementsByName("werbung").value;

var preis = v_clan*0.70+v_public*1.40+v_teamspeak*0.20+v_werbung*5.0;
var zusatz=0.0;

if (v_zeit == 1) zusatz=10.0;
else if (v_zeit == 3) zusatz=5.0;

document.bestell.monatlich.value=preis;
document.bestell.einmalig.value=zusatz;


}

</script>
<input name="monatlich" type="text" size="4" maxlength="5" />
Euro (Monatlich)
<br />
<input name="einmalig" type="text" size="4" maxlength="5" />
Euro (Setupgeb&uuml;hr) </td>
</tr>
</table>
</form>

Freundliche Grüße

Content-Key: 91351

Url: https://administrator.de/contentid/91351

Ausgedruckt am: 28.03.2024 um 12:03 Uhr

Mitglied: bytecounter
bytecounter 05.07.2008 um 11:08:19 Uhr
Goto Top
Hallo,

erstmal möchte ich Dich bitten, Code auch als Code zu posten.

Auf jeden Fall hast Du hier einen Fehler:

document.bestell.monatlich.value=preis;
document.bestell.einmalig.value=zusatz;

Insgesamt fällt mir auf, dass Du für die Ausgabe ein "normales" Inputfeld verwendest. Das sollte aber sinnvollerweise schreibgeschützt sein.

Probier mal folgendes (nur Codefragmente!):

...
<script language="javascript" type="text/javascript">  
  ...
  document.getElementById("ergebnis_monatlich").value = preis;  
  document.getElementById("ergebnis_einmalig").value = zusatz;  
</script>
...
<input id="ergebnis_monatlich" name="monatlich" type="text" size="4" maxlength="5"  readonly="readonly" />  
Euro (Monatlich)
<br />
<input id="ergebnis_einmalig" name="einmalig" type="text" size="4" maxlength="5"  readonly="readonly" />  
Euro (Setupgeb&uuml;hr) 
</td>
...

Der Code ist ungetestet!

vg
Bytecounter
Mitglied: jeaTreXs
jeaTreXs 05.07.2008 um 13:48:27 Uhr
Goto Top
Ja danke,

ich werds probieren,

was is der unterschied zwischen disabled und readonly?

// EDIT: hab schon (: danke übrigens: es funtkioniert.