|
|||
Funktion tofixed(2) veränder oder nach baun.
Moin Leute,
also ich habe für mein Onkel vor 2monaten ein Bestellformular in JS geschrieben und da brauch ich halt die Funktion tofixed(2) das Problem dabei ist nur das der das so macht 50.58 anstatt mit einem Komma 50,58 Hat da einer von euch ein Plan wie man die Funktion nachbaut oder verändern kann? THX schon mal MFG St4un3r |
Sponsored Links |
|
||||
„toFixed()“ hat offensichtlich nichts mit der Notation des Dezimaltrennzeichens zu tun, sondern kürzt lediglich auf die angegebene Nachkommastelle und rundet entsprechend, siehe auch:
SELFHTML: JavaScript / Objektreferenz / Number |
Sponsored Links |
|
||||
versuchs mal damit: SELFHTML: JavaScript / Objektreferenz / String
|
|
|||
Ich hoffe ihr habt mal lust mir das hier zu erklären wie ich das jetzt hin bekomme, da das hier meine erste sache in JS ist und ich mich damit nicht gerade gut aus kenne
Code:
<html> <head> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Bestellformular USB Taster</title> <META NAME="Copyright" CONTENT="Stefan Kater"> <style fprolloverstyle>A:hover {color: white; font-weight: bold; background-color: red} </style> <bgsound src="CD-1-de/Zusatz/LinK_Ton.wav" loop="1"> </head> <body link="#FF0000" vlink="#FF0000" alink="#FF0000" topmargin="0" leftmargin="0"> <a name="SeitenAnfang"></a> <!--Anfang Oberteihl --> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="940" height="107" id="AutoNumber6"> <tr> <td width="122" height="122" rowspan="3"> <img border="0" src="CD-1-de/Zusatz/Logo_CD-1.gif" width="122" height="122"></td> <td width="822" height="40"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber7" height="100%"> <tr> <td width="19%" nowrap align="center"><b><a href="USB-Taster.html">USB Taster</a></b></td> <td width="20%" nowrap align="center"> </td> <td width="20%" nowrap align="center"><b><font color="#ff0000"> <a href="Bestellformular-USB-Taster.html">Bestellformular</a></font></b></td> <td width="20%" nowrap align="center"> </td> <td width="21%" nowrap align="center"><font color="#111111"><b> <a href="AGB-USB-Taster.html">AGB & Kontakt</a></b></font></td> </tr> </table> </td> </tr> <tr> <th height="41" bgcolor="#FF0000" nowrap width="822"><font face="Verdana"><b> <font size="4" color="#FFFFFF"> </font></b><font color="#FFFFFF" size="4">USB Taster sendet Tasteneingaben an Windowssteuerung</font></font></th> </tr> <tr> <td width="822" height="41"> </td> </tr> </table> <!--Ende Oberteilh--> <div align="left"> <table border="0" width="947" height="1266" id="AutoNumber8" cellspacing="0"> <tr> <td width="31" height="19"> <form name="form1"></td> <td width="43" height="1264" rowspan="32"> <a href="#SeitenAnfang"> <img border="0" src="CD-1-de/Zusatz/1_Pixel_rot.bmp" width="100%" height="100%"></a></td> <td width="41" height="1264" rowspan="32"> </td> <td width="6" height="1264" rowspan="32" bordercolor="#EEEEEE" bgcolor="#EEEEEE"> </td> <td width="816" height="19" colspan="4" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> </td> </tr> <tr> <td width="39" height="1243" rowspan="31"> </td> <td width="816" height="32" colspan="4" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <font face="Arial"><b><font size="2">Die Bestellformulare benutzen keine Cookies und senden uns keine Daten. Sie laufen auch im Offlinebetrieb. Sie erzeugen nur einen <font color="#ff0000">formatierten Bestelltext, den Sie uns per Email senden müssen.</font></font></b></font></td> </tr> <tr> <td width="226" height="19" colspan="2" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> </td> <td width="487" height="19" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> </td> <td width="99" height="40" bordercolor="#E6E6E6" bgcolor="#EEEEEE" rowspan="2"> </td> </tr> <tr> <td width="226" height="19" colspan="2" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> </td> <td width="487" height="19" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> </td> </tr> <tr> <td width="226" height="19" colspan="2" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> </td> <td width="487" height="19" align="center" bordercolor="#E6E6E6" bgcolor="#EEEEEE"><b><font face="Verdana"> Warenkorb</font></b></td> <td width="99" height="19" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> </td> </tr> <tr> <td width="166" height="12" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <span style="font-size: 1">1111</span></td> <td width="58" height="12" align="right" bordercolor="#E6E6E6" bgcolor="#EEEEEE"></td> <td width="487" height="126" rowspan="4" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <textarea name="Warenkorb_ausgabe" rows="8" readonly="readonly" cols="58" tabindex="19"></textarea></td> <td width="99" height="126" rowspan="4" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> </td> </tr> <tr> <td height="32" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE" width="166"><font face="Verdana"> USB Taster</font></td> <td height="32" align="right" bordercolor="#E6E6E6" bgcolor="#EEEEEE" width="58"> <input name="USB_Taster" value="1" size="4" maxlength="4"></td> </tr> <tr> <td height="18" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE" width="166"><font face="Verdana">USB Kabel</font></td> <td height="18" align="right" bordercolor="#E6E6E6" bgcolor="#EEEEEE" width="58"> <input name="USB_Kabel" value="0" size="4" maxlength="4"></td> </tr> <tr> <td width="226" height="58" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE" colspan="2"> <input onclick=Warenkorb() type=button value="Warenkorb Aktualisieren" tabindex="18"></td> </tr> <tr> <td width="226" height="19" colspan="2" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> </td> <td width="588" height="19" colspan="2" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> </td> </tr> <tr> <td width="814" height="25" colspan="4" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"><b> <font face="Verdana" size="3">Bitte geben Sie für Ihre Bestellung unten Ihre Daten an.</font></b></td> </tr> <tr> <td width="816" height="19" colspan="4" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> </td> </tr> <tr> <td width="226" height="22" colspan="2" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"><font face="Verdana">Firma</font></td> <td width="588" height="22" colspan="2" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <input maxlength="30" size="30" name="Firma" tabindex="8" value="CD-1.de"></td> </tr> <tr> <td width="226" height="22" colspan="2" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"><font face="Verdana">Vorname*</font></td> <td width="588" height="22" colspan="2" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <input maxlength="30" size="30" name="Vorname" tabindex="8" value="Stefan"></td> </tr> <tr> <td width="226" height="22" colspan="2" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"><font face="Verdana">Nachname*</font></td> <td width="588" height="22" colspan="2" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <input maxlength="30" size="30" name="Nachname" tabindex="8" value="Kater"></td> </tr> <tr> <td width="226" height="22" colspan="2" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"><font face="Verdana">Straße + Nr.*</font></td> <td width="588" height="22" colspan="2" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <input maxlength="30" size="30" name="Strasse" tabindex="8" value="Folkebernadottestr. 24"></td> </tr> <tr> <td width="226" height="22" colspan="2" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"><font face="Verdana">Plz*</font></td> <td width="588" height="22" colspan="2" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <input maxlength="30" size="30" name="Plz" tabindex="8" value="23566"></td> </tr> <tr> <td width="226" height="22" colspan="2" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"><font face="Verdana">Ort*</font></td> <td width="588" height="22" colspan="2" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <input maxlength="30" size="30" name="Ort" tabindex="8" value="Lübeck"></td> </tr> <tr> <td width="226" height="22" colspan="2" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"><font face="Verdana">Tel*</font></td> <td width="588" height="22" colspan="2" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <input maxlength="30" size="30" name="Tel" tabindex="8" value="0451-63749"></td> </tr> <tr> <td width="226" height="22" colspan="2" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"><font face="Verdana">Fax</font></td> <td width="588" height="22" colspan="2" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <input maxlength="30" size="30" name="Fax" tabindex="8" value="0451-63759"></td> </tr> <tr> <td width="226" height="22" colspan="2" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"><font face="Verdana">E-Mail*</font></td> <td width="588" height="22" colspan="2" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <input maxlength="30" size="30" name="email" tabindex="8" value="stefankater1@cd-1.de"></td> </tr> <tr> <td width="816" height="6" colspan="4" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <span style="font-size: 1">1</span></td> </tr> <tr> <td width="816" height="20" colspan="4" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <font color="#FF0000" face="Verdana"> <b>AGB gelesen und akzeptiert </b> </font><input type="checkbox" name="agb" value="ON" tabindex="7" checked></td> </tr> <tr> <td width="816" height="7" colspan="4" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <span style="font-size: 1">1</span></td> </tr> <tr> <td width="816" height="43" colspan="4" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <INPUT onclick=chkFormular() type=button value="Formular prüfen und Bestelltext erzeugen" tabindex="18"><input type="reset" value="zurücksetzen" /></td> </tr> <tr> <td width="816" height="5" colspan="4" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <span style="font-size: 1">1</span></td> </tr> <tr> <td width="816" height="19" colspan="4" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"><b><font color="#ff0000">Bitte kopieren Sie den Bestelltext und senden ihn per Email an</font> <a href="mailto:brennservice@cd-1.de">brennservice@cd-1.de</a></b></td> </tr> <tr> <td width="816" height="3" colspan="4" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <span style="font-size: 1">1</span></td> </tr> <tr> <td width="816" height="533" colspan="4" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> <textarea name="Ausgabe" rows="31" readonly="readonly" cols="87" tabindex="19"></textarea></td> </tr> <tr> <td width="816" height="19" colspan="4" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> </td> </tr> <tr> <td width="816" height="27" colspan="4" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> </td> </tr> <tr> <td width="816" height="27" colspan="4" align="left" bordercolor="#E6E6E6" bgcolor="#EEEEEE"> </td> </tr> </table> </div> </body> <!--- Java Script Begint !---> <script language=JavaScript> /*Variable___________________________________________________________________________________*/ Ausgabe_2 = ""; Warenkorb_ausgabe_2 = ""; Preis_Taster_Gesamt = 0; Preis_Kabel_Gesamt = 0; Preis_Gesamt = 0; Netto = 0; MwSt_Preis = 0; MwSt = 1.19; USB_Taster_einzel_Preis = 58.00; USB_Kabel_einzel_Preis = 19.00; Versandkosten = 5.90; today = new Date(); month = today.getMonth()+1; year = today.getYear(); day = today.getDate(); if(day<10) day = "0" + day; if(month<10) month= "0" + month; if(year<1000) year=year + 1900; /*\\Datum___________________________________________________________________________________*/ /*********Berechne Preis___________________________________________________________________________________*/ function Berechne_Preis() { Preis_Taster_Gesamt = document.form1.USB_Taster.value * USB_Taster_einzel_Preis; Preis_Kabel_Gesamt = document.form1.USB_Kabel.value * USB_Kabel_einzel_Preis; Preis_Gesamt = Preis_Taster_Gesamt + Preis_Kabel_Gesamt + Versandkosten; Netto = Preis_Gesamt / MwSt; MwSt_Preis = Preis_Gesamt - Netto; return; } /*\\********Berechne Preis___________________________________________________________________________________*/ /*********Bestell Text___________________________________________________________________________________*/ function chkFormular() { Berechne_Preis() Ausgabe_2 = "Bestellung: An Firma CD-1.de Folkebernadottestr. 24 23566 Lübeck"+"\n"+"\n"+"\n"+"Auftraggeber:"; /*Firma___________________________________________________________________________________*/ Feld_Inhalt = document.form1.Firma.value VerbotteneZeichen() document.form1.Firma.value=Feld_Inhalt if(Kontrole==1) { alert("In der Zeile Firma sind verbotene Zeichen ( <> | ; : / \\ { } [ ] ° ^ \" § $ % & = ? `´ * + ~ # ' ) bitte schreiben Sie nur Buchstarben"); document.form1.Firma.focus(); return false; } Ausgabe_2 = Ausgabe_2 + "" +"\n"+document.form1.Firma.value; /*\\Firma___________________________________________________________________________________*/ /*Vorname___________________________________________________________________________________*/ if(document.form1.Vorname.value.length < 3) { alert ("Bitte geben Sie ihren Vornamen an!"); document.form1.Vorname.focus(); return false; } Feld_Inhalt = document.form1.Vorname.value VerbotteneZeichen() document.form1.Vorname.value=Feld_Inhalt if(Kontrole==1) { alert("In der Zeile Vorname sind verbotene Zeichen ( <> | ; : / \\ { } [ ] ° ^ \" § $ % & = ? `´ * + ~ # ' ) bitte schreiben Sie nur Buchstarben"); document.form1.Vorname.focus(); return false; } Ausgabe_2 = Ausgabe_2 + "" +"\n"+document.form1.Vorname.value; /*\\Vorname___________________________________________________________________________________*/ /*Nachname___________________________________________________________________________________*/ if(document.form1.Nachname.value.length < 3) { alert ("Bitte geben Sie ihren Nachnamen an!"); document.form1.Nachname.focus(); return false; } Feld_Inhalt = document.form1.Nachname.value VerbotteneZeichen() document.form1.Nachname.value=Feld_Inhalt if(Kontrole==1) { alert("In der Zeile Nachname sind verbotene Zeichen ( <> | ; : / \\ { } [ ] ° ^ \" § $ % & = ? `´ * + ~ # ' ) bitte schreiben Sie nur Buchstarben"); document.form1.Nachname.focus(); return false; } Ausgabe_2 = Ausgabe_2 + " " +document.form1.Nachname.value; /*\\Nachname___________________________________________________________________________________*/ /*Strasse + Nr.___________________________________________________________________________________*/ if(document.form1.Strasse.value.length < 3) { alert ("Bitte geben Sie ihre Strasse + Nr. an!"); document.form1.Strasse.focus(); return false; } Feld_Inhalt = document.form1.Strasse.value VerbotteneZeichen() document.form1.Strasse.value=Feld_Inhalt if(Kontrole==1) { alert("In der Zeile Strasse + Nr. sind verbotene Zeichen ( <> | ; : / \\ { } [ ] ° ^ \" § $ % & = ? `´ * + ~ # ' ) bitte schreiben Sie nur Buchstarben und Zahlen"); document.form1.Strasse.focus(); return false; } Ausgabe_2 = Ausgabe_2 + "" +"\n"+document.form1.Strasse.value; /*\\Strasse + Nr___________________________________________________________________________________*/ /*Plz___________________________________________________________________________________*/ if(document.form1.Plz.value.length < 3) { alert ("Bitte geben Sie ihre Plz. an!"); document.form1.Plz.focus(); return false; } Feld_Inhalt = document.form1.Plz.value VerbotteneZeichen() document.form1.Plz.value=Feld_Inhalt if(Kontrole==1) { alert("In der Zeile Plz sind verbotene Zeichen ( <> | ; : / \\ { } [ ] ° ^ \" § $ % & = ? `´ * + ~ # ' ) bitte schreiben Sie nur Zahlen"); document.form1.Plz.focus(); return false; } Ausgabe_2 = Ausgabe_2 + "" +"\n"+"\n"+document.form1.Plz.value; /*\\Plz___________________________________________________________________________________*/ /*Ort___________________________________________________________________________________*/ if(document.form1.Ort.value.length < 3) { alert ("Bitte geben Sie ihren Ort an!"); document.form1.Ort.focus(); return false; } Feld_Inhalt = document.form1.Ort.value VerbotteneZeichen() document.form1.Ort.value=Feld_Inhalt if(Kontrole==1) { alert("In der Zeile Ort sind verbotene Zeichen ( <> | ; : / \\ { } [ ] ° ^ \" § $ % & = ? `´ * + ~ # ' ) bitte schreiben Sie nur Buchstarben"); document.form1.Ort.focus(); return false; } Ausgabe_2 = Ausgabe_2 + " " +document.form1.Ort.value; /*\\Ort___________________________________________________________________________________*/ /*Tel.___________________________________________________________________________________*/ if(document.form1.Tel.value.length < 3) { alert ("Bitte geben Sie ihre Tel. Nummer an!"); document.form1.Tel.focus(); return false; } Feld_Inhalt = document.form1.Tel.value VerbotteneZeichen() document.form1.Tel.value=Feld_Inhalt if(Kontrole==1) { alert("In der Zeile Tel. sind verbotene Zeichen ( <> | ; : / \\ { } [ ] ° ^ \" § $ % & = ? `´ * + ~ # ' ) bitte schreiben Sie nur Zahlen"); document.form1.Tel.focus(); return false; } Ausgabe_2 = Ausgabe_2 + "" +"\n"+"Tel: "+document.form1.Tel.value; /*\\Tel.___________________________________________________________________________________*/ /*Fax___________________________________________________________________________________*/ Feld_Inhalt = document.form1.Fax.value VerbotteneZeichen() document.form1.Fax.value=Feld_Inhalt if(Kontrole==1) { alert("In der Zeile Fax sind verbotene Zeichen ( <> | ; : / \\ { } [ ] ° ^ \" § $ % & = ? `´ * + ~ # ' ) bitte schreiben Sie nur Zahlen"); document.form1.Fax.focus(); return false; } Ausgabe_2 = Ausgabe_2 + "" +"\n"+"Fax: "+document.form1.Fax.value; /*\\Fax___________________________________________________________________________________*/ /*E-Mail___________________________________________________________________________________*/ if(document.form1.email.value.length < 3) { alert ("Bitte geben Sie ihre E-Mail Adresse an!"); document.form1.email.focus(); return false; } Feld_Inhalt = document.form1.email.value VerbotteneZeichen() document.form1.email.value=Feld_Inhalt if(Kontrole==1) { alert("In der Zeile E-Mail sind verbotene Zeichen ( <> | ; : / \\ { } [ ] ° ^ \" § $ % & = ? `´ * + ~ # ' )"); document.form1.email.focus(); return false; } Ausgabe_2 = Ausgabe_2 + "" +"\n"+"Mail: "+document.form1.email.value; /*\\E-Mail___________________________________________________________________________________*/ /*Bestell Nr___________________________________________________________________________________*/ Bestell_Nr = document.form1.Vorname.value.substr(0,1)+document.form1.Nachname.value.substr(0,10)+document.form1.Ort.value.substr(0,10)+day+month+ (year+"").substring(2,4) /*\\Bestell Nr___________________________________________________________________________________*/ /*USB Taster___________________________________________________________________________________*/ Feld_Inhalt = document.form1.USB_Taster.value VerbotteneZeichen() document.form1.USB_Taster.value=Feld_Inhalt if(Kontrole==1) { alert("In der Zeile USB Taster sind verbotene Zeichen ( <> | ; : / \\ { } [ ] ° ^ \" § $ % & = ? `´ * + ~ # ' ) bitte schreiben Sie nur Zahlen"); document.form1.USB_Taster.focus(); return false;r } if(isNaN(document.form1.USB_Taster.value) == true) { alert("In der Zeile USB Taster ist keine Zahl"); document.form1.USB_Taster.focus(); return false; } if(document.form1.USB_Taster.value < 0 && document.form1.USB_Taster.value > 1000) { alert("Bitte geben Sie in der Zeile USB Taster nur Zahlen von 0 bis 1000 ein"); document.form1.USB_Taster.focus(); return false; } Ausgabe_2 = Ausgabe_2 + "" +"\n"+"\n"+"Bestellung: Bestellnummer "+Bestell_Nr+"\n"+"\n"+"Menge Artikel EP GP"+"\n"; if(document.form1.USB_Taster.value.length > 0 ) Laengausgleich = " " if(document.form1.USB_Taster.value.length > 1 ) Laengausgleich = " " if(document.form1.USB_Taster.value.length > 2 ) Laengausgleich = " " if(document.form1.USB_Taster.value.length > 3 ) Laengausgleich = " " if(document.form1.USB_Taster.value > 0) { Ausgabe_2 = Ausgabe_2 + "" +"\n"+document.form1.USB_Taster.value +Laengausgleich +" USB Taster " +USB_Taster_einzel_Preis.toFixed(2)+" Euro "+Preis_Taster_Gesamt.toFixed(2)+" Euro"; } /*\\USB Taster___________________________________________________________________________________*/ /*USB Kabel___________________________________________________________________________________*/ Feld_Inhalt = document.form1.USB_Kabel.value VerbotteneZeichen() document.form1.USB_Kabel.value=Feld_Inhalt if(Kontrole==1) { alert("In der Zeile USB Kabel sind verbotene Zeichen ( <> | ; : / \\ { } [ ] ° ^ \" § $ % & = ? `´ * + ~ # ' ) bitte schreiben Sie nur Zahlen"); document.form1.USB_Kabel.focus(); return false;r } if(isNaN(document.form1.USB_Kabel.value) == true) { alert("In der Zeile USB Kabel ist keine Zahl"); document.form1.USB_Kabel.focus(); return false; } if(document.form1.USB_Kabel.value < 0 || document.form1.USB_Kabel.value > 1000) { alert("Bitte geben Sie in der Zeile USB Kabel nur Zahlen von 0 bis 1000 ein"); document.form1.USB_Kabel.focus(); return false; } if(document.form1.USB_Kabel.value.length > 0) Laengausgleich = " " if(document.form1.USB_Kabel.value.length > 1) Laengausgleich = " " if(document.form1.USB_Kabel.value.length > 2) Laengausgleich = " " if(document.form1.USB_Kabel.value.length > 3) Laengausgleich = " " if(document.form1.USB_Kabel.value > 0) { Ausgabe_2 = Ausgabe_2 + "" +"\n"+document.form1.USB_Kabel.value +Laengausgleich +" USB Kabel "+USB_Kabel_einzel_Preis.toFixed(2)+" Euro "+Preis_Kabel_Gesamt.toFixed(2)+" Euro"; } /*\\USB Kabel ___________________________________________________________________________________*/ /*Gesamt Preis___________________________________________________________________________________*/ Ausgabe_2 = Ausgabe_2 + "" +"\n"+"1 Versandkosten "+Versandkosten.toFixed(2)+" Euro "+Versandkosten.toFixed(2)+" Euro"+"\n"+"\n"+"Netto:"+Netto.toFixed(2)+" Euro"+" MwSt:"+MwSt_Preis.toFixed(2)+" Euro"+"\n"+"Gesamter Rechnungsbetrag inkl. 19% MwSt. "+Preis_Gesamt.toFixed(2)+" Euro"+"\n"+"\n"+"Bitte zahlen Sie den Rechnungsbetrag von "+Preis_Gesamt.toFixed(2)+" Euro per Vorkasse"+"\n"+"Verwendungszweck "+Bestell_Nr+"\n"+"Versand erfolgt 3 bis 5 Arbeitstage nach Geldeingang."+"\n"+"Unsere Bankverbindung bekommen Sie mit der Auftragsbestätigung."+"\n"+"\n"+"Der Auftraggeber bestätig alle Angaben und akzeptiert unsere AGB."; /*\\Gesamt Preis ___________________________________________________________________________________*/ /*AGB ___________________________________________________________________________________*/ if(document.form1.agb.checked == false) { alert ("Sie müssen unseren AGB zustimmen, um bei uns bestellen zu können!") document.form1.agb.focus() return false; } /*\\AGB ___________________________________________________________________________________*/ /*Warenkorb cheack ___________________________________________________________________________________*/ if(document.form1.USB_Kabel.value < 1 && document.form1.USB_Taster.value < 1) { document.form1.Warenkorb_ausgabe.focus(); document.form1.Warenkorb_ausgabe.value = ""; document.form1.Ausgabe.value =""; alert("Der Warenkorb ist leer!"); return false; } /*\\Warenkorb cheack ___________________________________________________________________________________*/ document.form1.Ausgabe.value = Ausgabe_2; document.form1.Ausgabe.focus(); return; } /*\\********Bestell Text___________________________________________________________________________________*/ /*********Warenkorb___________________________________________________________________________________*/ function Warenkorb() { Berechne_Preis(); Warenkorb_ausgabe_2 = "Menge Artikel EP GP"; /*USB Taster___________________________________________________________________________________*/ Feld_Inhalt = document.form1.USB_Taster.value VerbotteneZeichen() document.form1.USB_Taster.value=Feld_Inhalt if(Kontrole==1) { alert("In der Zeile USB Taster sind verbotene Zeichen ( <> | ; : / \\ { } [ ] ° ^ \" § $ % & = ? `´ * + ~ # ' ) bitte schreiben Sie nur Zahlen"); document.form1.USB_Taster.focus(); return false;r } if(isNaN(document.form1.USB_Taster.value) == true) { alert("In der Zeile USB Taster ist keine Zahl"); document.form1.USB_Taster.focus(); return false; } if(document.form1.USB_Taster.value < 0 && document.form1.USB_Taster.value > 1000) { alert("Bitte geben Sie in der Zeile USB Taster nur Zahlen von 0 bis 1000 ein"); document.form1.USB_Taster.focus(); return false; } if(document.form1.USB_Taster.value.length > 0 ) Laengausgleich = " " if(document.form1.USB_Taster.value.length > 1 ) Laengausgleich = " " if(document.form1.USB_Taster.value.length > 2 ) Laengausgleich = " " if(document.form1.USB_Taster.value.length > 3 ) Laengausgleich = " " if(document.form1.USB_Taster.value > 0) { Warenkorb_ausgabe_2 = Warenkorb_ausgabe_2 +"" +"\n"+document.form1.USB_Taster.value +Laengausgleich +" USB Taster "+USB_Taster_einzel_Preis.toFixed(2)+" Euro "+Preis_Taster_Gesamt.toFixed(2)+" Euro"+"\n"; } if(document.form1.USB_Taster.value < 1) { Warenkorb_ausgabe_2 = Warenkorb_ausgabe_2 +"" +"\n"+"\n"; } /*\\USB Taster___________________________________________________________________________________*/ /*USB Kabel___________________________________________________________________________________*/ Feld_Inhalt = document.form1.USB_Kabel.value VerbotteneZeichen() document.form1.USB_Kabel.value=Feld_Inhalt if(Kontrole==1) { alert("In der Zeile USB Kabel sind verbotene Zeichen ( <> | ; : / \\ { } [ ] ° ^ \" § $ % & = ? `´ * + ~ # ' ) bitte schreiben Sie nur Zahlen"); document.form1.USB_Kabel.focus(); return false;r } if(isNaN(document.form1.USB_Kabel.value) == true) { alert("In der Zeile USB Kabel ist keine Zahl"); document.form1.USB_Kabel.focus(); return false; } if(document.form1.USB_Kabel.value < 0 || document.form1.USB_Kabel.value > 1000) { alert("Bitte geben Sie in der Zeile USB Kabel nur Zahlen von 0 bis 1000 ein"); document.form1.USB_Kabel.focus(); return false; } if(document.form1.USB_Kabel.value.length > 0) Laengausgleich = " " if(document.form1.USB_Kabel.value.length > 1) Laengausgleich = " " if(document.form1.USB_Kabel.value.length > 2) Laengausgleich = " " if(document.form1.USB_Kabel.value.length > 3) Laengausgleich = " " if(document.form1.USB_Kabel.value > 0) { Warenkorb_ausgabe_2 = Warenkorb_ausgabe_2 +"" +"\n"+document.form1.USB_Kabel.value +Laengausgleich +" USB Kabel "+USB_Kabel_einzel_Preis.toFixed(2)+" Euro "+Preis_Kabel_Gesamt.toFixed(2)+" Euro" +"\n"+"\n"+"1 Versandkosten "+Versandkosten.toFixed(2)+" Euro "+Versandkosten.toFixed(2)+" Euro"+"\n"+"Netto:"+Netto.toFixed(2)+" Euro"+" MwSt:"+MwSt_Preis.toFixed(2)+" Euro"+"\n"+"Gesamter Rechnungsbetrag inkl. 19% MwSt. "+Preis_Gesamt.toFixed(2)+" Euro"; } if(document.form1.USB_Kabel.value < 1) { Warenkorb_ausgabe_2 = Warenkorb_ausgabe_2 +"" +"\n"+"\n"+"\n"+"1 Versandkosten "+Versandkosten.toFixed(2)+" Euro "+Versandkosten.toFixed(2)+" Euro"+"\n"+"Netto:"+Netto.toFixed(2)+" Euro"+" MwSt:"+MwSt_Preis.toFixed(2)+" Euro"+"\n"+"Gesamter Rechnungsbetrag inkl. 19% MwSt. "+Preis_Gesamt.toFixed(2)+" Euro"; } /*\\USB Kabel ___________________________________________________________________________________*/ if(document.form1.USB_Kabel.value < 1 && document.form1.USB_Taster.value < 1) { document.form1.Warenkorb_ausgabe.focus(); document.form1.Warenkorb_ausgabe.value = ""; document.form1.Ausgabe.value =""; alert("Der Warenkorb ist leer!"); return false; } document.form1.Warenkorb_ausgabe.value = Warenkorb_ausgabe_2; document.form1.Warenkorb_ausgabe.focus(); return; } /*\\********Warenkorb ___________________________________________________________________________________*/ /*********Verbottene Zeichen___________________________________________________________________________________*/ function VerbotteneZeichen() { Z0=Feld_Inhalt Feld_Inhalt=NurEinLeerZeichen() Kontrole=0 if(Feld_Inhalt.indexOf("<") != -1) Kontrole=1 if(Feld_Inhalt.indexOf(">") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("\"") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("#") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("'") != -1) Kontrole=1 if(Feld_Inhalt.indexOf(":") != -1) Kontrole=1 if(Feld_Inhalt.indexOf(";") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("*") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("\\") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("/") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("}") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("{") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("[") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("]") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("?") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("+") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("|") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("=") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("°") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("§") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("$") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("%") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("&") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("~") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("`") != -1) Kontrole=1 if(Feld_Inhalt.indexOf("´") != -1) Kontrole=1 /*tab und return gegen Leerzeichen tauschen */ while(Feld_Inhalt.indexOf("\n")!=-1)Feld_Inhalt=Feld_Inhalt.slice(0,Feld_Inhalt.indexOf("\n")-1)+" "+Feld_Inhalt.slice(Feld_Inhalt.indexOf("\n")+1) while(Feld_Inhalt.indexOf(" ")!=-1)Feld_Inhalt=Feld_Inhalt.slice(0,Feld_Inhalt.indexOf(" "))+" "+Feld_Inhalt.slice(Feld_Inhalt.indexOf(" ")+1) if(Feld_Inhalt.length<240)return alert("In Zeile 13 (Text) dürfen max 240 Zeichen eingeben werden"+"\n"+"Restlichen Zeichen werden gelöscht") Feld_Inhalt=Feld_Inhalt.slice(0,239) return } /*\\********Verbottene Zeichen___________________________________________________________________________________*/ /*********Anfang_NurEinLeerZeichen___________________________________________________________________________________*/ function NurEinLeerZeichen() { while(Z0.indexOf(" "+" ")!=-1)Z0=Z0.slice(0,Z0.indexOf(" "+" "))+Z0.slice(Z0.indexOf(" "+" ")+1) if(Z0.slice(0,1)==" ")Z0=Z0.slice(1) if(Z0.slice(Z0.length-1,Z0.length)==" ")Z0=Z0.slice(0,Z0.length-1) return Z0 } /*\\********Anfang_NurEinLeerZeichen___________________________________________________________________________________*/ Warenkorb(); </script> </html> |
|
|||
Also ich habe den code auf Variablen und Ausgaben gekürzt
Variablen Code:
/*Variable___________________________________________________________________________________*/ Ausgabe_2 = ""; Warenkorb_ausgabe_2 = ""; Preis_Taster_Gesamt = 0; Preis_Kabel_Gesamt = 0; Preis_Gesamt = 0; Netto = 0; MwSt_Preis = 0; MwSt = 1.19; USB_Taster_einzel_Preis = 58.00; USB_Kabel_einzel_Preis = 19.00; Versandkosten = 5.90; today = new Date(); month = today.getMonth()+1; year = today.getYear(); day = today.getDate(); if(day<10) day = "0" + day; if(month<10) month= "0" + month; if(year<1000) year=year + 1900; /*\\Datum___________________________________________________________________________________*/ /*********Berechne Preis___________________________________________________________________________________*/ function Berechne_Preis() { Preis_Taster_Gesamt = document.form1.USB_Taster.value * USB_Taster_einzel_Preis; Preis_Kabel_Gesamt = document.form1.USB_Kabel.value * USB_Kabel_einzel_Preis; Preis_Gesamt = Preis_Taster_Gesamt + Preis_Kabel_Gesamt + Versandkosten; Netto = Preis_Gesamt / MwSt; MwSt_Preis = Preis_Gesamt - Netto; return; } /*\\********Berechne Code:
if(document.form1.USB_Taster.value > 0) { Ausgabe_2 = Ausgabe_2 + "" +"\n"+document.form1.USB_Taster.value +Laengausgleich +" USB Taster " +USB_Taster_einzel_Preis.toFixed(2)+" Euro "+Preis_Taster_Gesamt.toFixed(2)+" Euro"; } ********************* if(document.form1.USB_Kabel.value > 0) { Ausgabe_2 = Ausgabe_2 + "" +"\n"+document.form1.USB_Kabel.value +Laengausgleich +" USB Kabel "+USB_Kabel_einzel_Preis.toFixed(2)+" Euro "+Preis_Kabel_Gesamt.toFixed(2)+" Euro"; } |
Themen-Optionen | |
Ansicht | |
|
|
Ähnliche Themen | ||||
Thema | Autor | Forum | Antworten | Letzter Beitrag |
[PROTOTYPE] Funktion erst beenden, wenn Ajax Aufruf abgeschlossen ist | naitsab | Javascript & Ajax | 3 | 09.04.2009 16:41 |
Code einer bestehenden Funktion hinzufügen | cybertron | Javascript & Ajax | 13 | 01.01.2009 16:53 |
Mit setTimeout funktion im eigenen Objekt aufrufen | PoWl | Javascript & Ajax | 5 | 11.05.2008 11:35 |
Funktion gibt Array nicht zurück | Schneemann | Serveradministration und serverseitige Scripte | 8 | 05.05.2008 02:14 |
[PHP] Funktion zum Optimieren von CSS | Floele | Serveradministration und serverseitige Scripte | 2 | 13.08.2005 11:31 |