uptodate-24 KalkulatorKundeKundennummer, wenn verfügbarNachnameVornameTelefonmobilE-MailabstandshalteGlas linksGlas rechtsFassungDienstleistung 1Dienstleistung 2SonstigesSummeRabatt in %%-Rabatt in €weiterer Rabatt in €BarpreisLaufzeiteinmalige UTD-24 Teilnahme-GebührfinanzierungNeinJaLabel TextLabel TextLabel TextLabel TextLabel TextLabel TextPowered By ChronoForms - ChronoEngine.com"> Javascript just work half - Forums

Forums

Javascript just work half

Breakbeatz 07 Sep, 2013
Hello,

first: Sorry for my bad English!!!
I installed Chronoform V4 on joomla 3.1.5, everythings fine.
Now i designed my first form with som javascripts, but just the half of it will works, and i dont know why, theres an Error-Report from Konsole (FF):
TypeError: barpreis1 is not a function
add1();perc1();barpreis1();geb1();rate1();kommazup unkt(zahl);

And hers the code:
function kommazupunkt(zahl) {
    zahl=zahl.toString();
    zahl=zahl.replace(/\,/,".");
    zahl=parseFloat(zahl);
    return zahl;
  }

  function perc1() {
    r=document.getElementById("rabatt1").value;
    s=document.getElementById("summe1").value;
    r=kommazupunkt(r);
    s=kommazupunkt(s);
    erg=s*(r/100);
    document.getElementById("euro1").value = erg.toFixed(2);
  }

  function barpreis1() {
          s=document.getElementById("summe1").value;
          n=document.getElementById("nachlass1").value;
          e=document.getElementById("euro1").value;
          s=kommazupunkt(s);
          n=kommazupunkt(n);
          e=kommazupunkt(e);
          erg=s-n-e;
          document.getElementById("barpreis1").value = erg.toFixed(2);
  }

 function geb1() {
    s=document.getElementById("summe1").value;
    s=kommazupunkt(s);
        erg=s*0.1;
    document.getElementById("geb1").value = erg.toFixed(2);
  }

  function add1() {
         gr=document.getElementById("gr1").value;
         gl=document.getElementById("gl1").value;
        f=document.getElementById("fass1").value;
        d1=document.getElementById("dstlg1_1").value;
        d2=document.getElementById("dstlg2_1").value;
        s=document.getElementById("sonstg1").value;
        gr=kommazupunkt(gr);
          gl=kommazupunkt(gl);
          f=kommazupunkt(f);
        d1=kommazupunkt(d1);
          d2=kommazupunkt(d2);
          s=kommazupunkt(s);
        erg=gl+gr+f+d1+d2+s;
    document.getElementById("summe1").value = erg.toFixed(2);
  }
  function rate1() {
        s=document.getElementById("summe1").value;
        m=document.getElementById("mon1").value;
        s=kommazupunkt(s);
        m=kommazupunkt(m);
        erg=s/m;
        document.getElementById("rate1").value = erg.toFixed(2);
  }		//]]>
		
  </script>

	
</head>
<body class="contentpane" id="jsn-content-popup">
	
<div id="system-message-container">
<div id="system-message">
</div>
</div>
<form action="http://inst.uptodate-24.de/index.php?option=com_chronoforms&tmpl=component&chronoform=test&event=submit" name="test" id="chronoform_test" method="post" class="Chronoform">

<div class="ccms_form_element cfdiv_header" 
id="id1_container_div" 
style=""><p>uptodate-24 Kalkulator</p>
<div class="clear"></div>
</div>
<div class="ccms_form_element cfdiv_text" id="kunde_container_div" style="">
<label for="Kunde">Kunde</label><input id="Kunde" maxlength="150" size="30" class="" title="" type="text" value="" name="kunde" />
<div class="small-message">Kundennummer, wenn verfügbar</div><div class="clear"></div><div id="error-message-kunde"></div></div><div class="ccms_form_element cfdiv_text multiline_start" id="nachname_container_div" style=""><label for="nachname">Nachname</label><input id="nachname" maxlength="150" size="30" class=" validate['required']" title="" type="text" value="" name="nachname" />
<div class="clear"></div><div id="error-message-nachname"></div></div><div class="ccms_form_element cfdiv_text multiline_add" id="_vorname_container_div" style=""><label for="#vorname">Vorname</label><input id="#vorname" maxlength="150" size="30" class=" validate['required','alpha']" title="" type="text" value="" name="vorname" />
<div class="clear"></div><div id="error-message-vorname"></div></div><div class="ccms_form_element cfdiv_text multiline_start" id="telefon1_container_div" style=""><label>Telefon</label><input maxlength="150" size="30" class=" validate['phone']" title="" type="text" value="" name="telefon" />
<div class="clear"></div><div id="error-message-telefon"></div></div><div class="ccms_form_element cfdiv_text multiline_add" id="mobil1_container_div" style=""><label>mobil</label><input maxlength="150" size="30" class=" validate['phone']" title="" type="text" value="" name="mobil" />
<div class="clear"></div><div id="error-message-mobil"></div></div><div class="ccms_form_element cfdiv_text" id="mail1_container_div" style=""><label>E-Mail</label><input maxlength="150" size="30" class=" validate['email']" title="" type="text" value="" name="mail" />
<div class="clear"></div><div id="error-message-mail"></div></div><div class="ccms_form_element cfdiv_header" id="id2_container_div" style="">abstandshalte<div class="clear"></div></div><div class="ccms_form_element cfdiv_text multiline_start" id="gl1_container_div" style=""><label for="gl1">Glas links</label><input id="gl1" maxlength="150" size="30" class=" validate['number']" title="gl1" type="text" value="0,00" name="gl1" />
<div class="clear"></div><div id="error-message-gl1"></div></div><div class="ccms_form_element cfdiv_text" id="gr1_container_div" style=""><label for="gr1">Glas rechts</label><input id="gr1" maxlength="150" size="30" class=" validate['number']" title="gr1" type="text" value="0,00" name="gr1" />
<div class="clear"></div><div id="error-message-gr1"></div></div><div class="ccms_form_element cfdiv_text" id="fass1_container_div" style=""><label for="fass1">Fassung</label><input id="fass1" maxlength="150" size="30" class=" validate['number']" title="fass1" type="text" value="0,00" name="fass1" />
<div class="clear"></div><div id="error-message-fass1"></div></div><div class="ccms_form_element cfdiv_text" id="dstlg1_1_container_div" style=""><label for="dstlg1_1">Dienstleistung 1</label><input id="dstlg1_1" maxlength="150" size="30" class="" title="dstlg1_1" type="text" value="0,00" name="input_text_5" />
<div class="clear"></div><div id="error-message-input_text_5"></div></div><div class="ccms_form_element cfdiv_text" id="dstlg2_1_container_div" style=""><label for="dstlg2_1">Dienstleistung 2</label><input id="dstlg2_1" maxlength="150" size="30" class="" title="dstlg2_1" type="text" value="0,00" name="dstlg2_1" />
<div class="clear"></div><div id="error-message-dstlg2_1"></div></div><div class="ccms_form_element cfdiv_text" id="sonstg1_container_div" style=""><label for="sonstg1">Sonstiges</label><input id="sonstg1" maxlength="150" size="30" class="" title="sonstg1" type="text" value="0,00" name="sonstg1" />
<div class="clear"></div><div id="error-message-sonstg1"></div></div><div class="ccms_form_element cfdiv_text" id="summe1_container_div" style=""><label for="summe1">Summe</label><input id="summe1" maxlength="150" size="30" class="" title="summe1" type="text" value="0,00" name="summe1" />
<div class="clear"></div><div id="error-message-summe1"></div></div><div class="ccms_form_element cfdiv_text" id="rabatt1_container_div" style=""><label for="rabatt1">Rabatt in %</label><input id="rabatt1" maxlength="150" size="30" class="" title="" type="text" value="" name="rabatt1" />
<div class="clear"></div><div id="error-message-rabatt1"></div></div><div class="ccms_form_element cfdiv_text" id="euro1_container_div" style=""><label for="euro1">%-Rabatt in €</label><input id="euro1" maxlength="150" size="30" class="" title="" type="text" value="0,00" name="euro1" />
<div class="clear"></div><div id="error-message-euro1"></div></div><div class="ccms_form_element cfdiv_text" id="nachlass1_container_div" style=""><label for="nachlass1">weiterer Rabatt in €</label><input id="nachlass1" maxlength="150" size="30" class="" title="" type="text" value="0,00" name="nachlass1" />
<div class="clear"></div><div id="error-message-nachlass1"></div></div><div class="ccms_form_element cfdiv_text" id="barpreis1_container_div" style=""><label for="barpreis1">Barpreis</label><input id="barpreis1" maxlength="150" size="30" class="" title="barpreis1" type="text" value="0,00" name="barpreis1" />
<div class="clear"></div><div id="error-message-barpreis1"></div></div><div class="ccms_form_element cfdiv_text" id="mon1_container_div" style=""><label for="mon1">Laufzeit</label><input id="mon1" maxlength="150" size="30" class="" title="mon1" type="text" value="24" name="mon1" />
<div class="clear"></div><div id="error-message-mon1"></div></div><div class="ccms_form_element cfdiv_text" id="geb1_container_div" style=""><label for="geb1">einmalige UTD-24 Teilnahme-Gebühr</label><input id="geb1" maxlength="150" size="30" class="" title="geb1" type="text" value="0,00" name="geb1" />
<div class="clear"></div><div id="error-message-geb1"></div></div><div class="ccms_form_element cfdiv_submit" id="calc_container_div" style="text-align:left"><input name="Berechne" id="calc" class="" value="berechne" type="button"  onClick="add1();perc1();barpreis1();geb1();rate1();kommazupunkt(zahl);"/>
<div class="clear"></div><div id="error-message-Berechne"></div></div><div class="ccms_form_element cfdiv_select" id="input_select_241_container_div" style=""><label>finanzierung</label><select size="1" class="" title="" name="input_select_24">
<option value="No">Nein</option>
<option value="Yes">Ja</option>
</select>
<div class="clear"></div><div id="error-message-input_select_24"></div></div><div class="ccms_form_element cfdiv_text" id="input_text_161_container_div" style=""><label>Label Text</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="input_text_16" />
<div class="clear"></div><div id="error-message-input_text_16"></div></div><div class="ccms_form_element cfdiv_text" id="input_text_171_container_div" style=""><label>Label Text</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="input_text_17" />
<div class="clear"></div><div id="error-message-input_text_17"></div></div><div class="ccms_form_element cfdiv_checkbox" id="input_checkbox_181_container_div" style=""><input type="hidden" name="input_checkbox_18" value="" alt="ghost" />
<input value="1" title="" type="checkbox" name="input_checkbox_18" id="input_checkbox_18" class="label_left" />
<label for="input_checkbox_18">Label Text</label><div class="clear"></div><div id="error-message-input_checkbox_18"></div></div><div class="ccms_form_element cfdiv_checkbox" id="input_checkbox_211_container_div" style=""><input type="hidden" name="input_checkbox_21" value="" alt="ghost" />
<input value="1" title="" type="checkbox" name="input_checkbox_21" id="input_checkbox_21" class="label_left" />
<label for="input_checkbox_21">Label Text</label><div class="clear"></div><div id="error-message-input_checkbox_21"></div></div><div class="ccms_form_element cfdiv_checkbox" id="input_checkbox_221_container_div" style=""><input type="hidden" name="input_checkbox_22" value="" alt="ghost" />
<input value="1" title="" type="checkbox" name="input_checkbox_22" id="input_checkbox_22" class="label_left" />
<label for="input_checkbox_22">Label Text</label><div class="clear"></div><div id="error-message-input_checkbox_22"></div></div><div class="ccms_form_element cfdiv_submit" id="sende_container_div" style="text-align:left"><input name="input_submit_25" id="sende" class="" value="sende" type="submit" />
<div class="clear"></div><div id="error-message-input_submit_25"></div></div><div class="ccms_form_element cfdiv_text" id="input_text_331_container_div" style=""><label>Label Text</label><input maxlength="150" size="30" class="" title="" type="text" value="" name="input_text_33" />
<div class="clear"></div><div id="error-message-input_text_33"></div></div><div class="ccms_form_element cfdiv_empty" id="empty_container_div" style=""><div class="clear"></div><div id="error-message-empty"></div></div><input type="hidden" name="7711b33f36cae074efbf106a452bb6ed" value="1" /></form><div class="chronoform"><a href="http://www.chronoengine.com">Powered By ChronoForms - ChronoEngine.com</a></div>
</body>
</html>
GreyHead 08 Sep, 2013
Hi Breakbeatz,

I don't see anything obviously wrong here :-(

One of the great joys of writing JavaScript is that you then get to debug it :-)

Bob
Breakbeatz 08 Sep, 2013
Hi Bob,

thanks for your answer.
When I debug the original code, like I saved at chronoforms, it shows me no errors, but when I test the page, it shows me the following error, but I can't find this line:
"TypeError: document.getElementById(...) is null (line 93)"

But I'm not sure, if I do everything correct...;-) ...cause I'm a newbie...
GreyHead 08 Sep, 2013
Hi Breakbeatz,

And what is on line 93?

Bob
This topic is locked and no more replies can be posted.