Forums

calculate live

bambid 09 Aug, 2013
Hello
I tried to make a form witch is calculate on the fly. But it does not work. Here is the code of the JS onload:
window.addEvent('load', function() {
   current_auswahl = 8;
   spalten = $('spalten1');
   hoehemm = $('hoehemm1');
   
.addEvent('onclick', function() {
erscheinungen = $$('.Chronoform checkbox:checked').length;
    if(erscheinungen > 3){
        var rabatt = 10;
    };
}
    
    // get the current value of the input field
    spalten.addEvent('keyup', function() {
        value_spalten = spalten.value;
  
  value_totalmm = value_spalten * value_mm;
    value_totalpreis = value_totalmm * 1.15 * current_auswahl;
    value_wrabatt = value_totalpreis / 100*rabatt;
    value_totalinkl = value_totalpreis - value_wrabatt;
  
    $('spalten').innerHTML = value_spalten;  
    $('hoehemm').innerHTML = value_mm;
    $('totalmm').innerHTML = value_totalmm;
    $('totalpreis').innerHTML = value_totalpreis;
    $('wrabatt').innerHTML = wrabatt;
    $('totalinkl').innerHTML = value_totalinkl;
    $('preisersch').innerHTML = value_totalinkl / rabatt;
});
 
    hoehemm.addEvent('keyup', function() { 
value_mm2 = hoehemm.value;
value_mm = value_mm2.length;
   
    
    value_totalmm = value_spalten * value_mm;
    value_totalpreis = value_totalmm * 1.15 * current_auswahl;
    value_wrabatt = value_totalpreis / 100*rabatt;
    value_totalinkl = value_totalpreis - value_wrabatt;
  
    $('spalten').innerHTML = value_spalten;  
    $('hoehemm').innerHTML = value_mm;
    $('totalmm').innerHTML = value_totalmm;
    $('totalpreis').innerHTML = value_totalpreis;
    $('wrabatt').innerHTML = wrabatt;
    $('totalink').innerHTML = value_totalink;
    $('preisersch').innerHTML = value_totalinkl / rabatt;
}); });


i got a Checkbox group (erscheinungen)
textfield (spalten1)
textfield (hoehemm1)

The value_mm is the VALUE of 'hoehemm'
The value_spalten is the VALUE of 'spalten'
The 'erscheinungen' is the VALUE of counted checkboxes
The 'rabatt' is 10 if 'erscheinungen' > 3


value_mm * value_spalten is the result 'totalmm'
totalpreis is the Product from 'totalmm' * 1.15

The 'wrabatt' is 'totalprise' / 100 * 'rabatt'

End Prise is: totalpreis - wrabatt

and The results should be displayd like this under the hoehemm field:
<h4>Höhe  <span id='hoehemm'>50</span></h4>
<h4>Spalten  <span id='spalten'>0</span></h4>
<h4>Total mm  <span id='totalmm'>0</span></h4>
<h4>Preis     <span id='totalpreis'>0</span></h4>
<h4>Wiederholungsrabatt  <span id='wrabatt'>0</span></h4>
<h4>Total Preis nach Abzug des Rabattes  <span id='totalinkl'>0</span></h4>
<h4>Preis pro Erscheinung  <span id='preisersch'>0</span></h4>


So how i get this, is this Possible or is this only a fiction?

Sorry about my English but this is not my favorit language.

Thanks for your help.

bambid
GreyHead 09 Aug, 2013
Hi bambid,

In general we don't debug user custom scripts for them but here I noticed a couple of things in this block of code:
  .addEvent('onclick', function() { // you need an element here xxx.addEvent( 
    erscheinungen = $$('.Chronoform checkbox:checked').length;
    if (erscheinungen > 3) {
      var rabatt = 10;
    };
  }); // the closing brackets are missing.

Bob
bambid 09 Aug, 2013
Hello Bob
Sorry but my question was is it possible a live calculating to do in a form or not. With those elements? the Rest i would try to figured out.

Thanks bambid
GreyHead 09 Aug, 2013
Hi bambid,

Yes it is possible.

Bob
bambid 20 Aug, 2013
i did it!

i had an .addEvent('onclick', function() {

now it Works!

thanks
bambid
GreyHead 20 Aug, 2013
Hi bambid,

Well done!!

Sorry I didn't spot that :-(

Bob
bambid 21 Aug, 2013
Hello Bob

Is it possible to get the Variable
<h4>Total Preis nach Abzug des Rabattes  <span id='totalinkl'>0</span></h4>


Inside the Mail witch i send to my costumer?

If yes, please give me a hint.

Thanks
bambid
GreyHead 21 Aug, 2013
Hi Bambid,

Add a hidden input to your form with say id='xx_price'.

Have your JavaScript set the value of the input $('xx_price') = . . . ;

Use {xx_price} in the Email template: <h4>Total Preis nach Abzug des Rabattes
<span id='totalinkl'>{xx_price}</span></h4>

Bob
bambid 24 Oct, 2013
Hi Bob, I tried the "preis" to pass, unfortunately it did not work. I tried it with diffrent variants. ".InnerHTML" then the "$('preis').input)=" but unfortunately without success. I've ried to examine the results in the debugger, but this is still empty.

What else can I do about it now?

I need the price that I can send it directly to paypal.

I ask you just to help me. if you still need more information, then you can feel free to contact me.

The Form can you find under:
http://www.fricktal.info/index.php?option=com_chronoforms&tmpl=component&chronoform=Kleinanzeigen

Best regards
bambid
GreyHead 25 Oct, 2013
Hi bambid,

I see this error
ReferenceError: kosten is not defined
rabatt_bet = kosten/100*rabatt;


You also seem to have two versions of MooTools loading though I'm not sure that is causing any problems.

Bob
bambid 25 Oct, 2013
Hello Bob

I do not know where you got this error happens. To me when I get to the debugger this display:

Data Array:

Array
(
    [option] => com_chronoforms
    [tmpl] => component
    [chronoform] => Kleinanzeigen
    [event] => submit
    [Itemid] => 
    [name] => 
    [input_text_7] => 34
    [input_radio_2] => ErSie
    [text] => 34
    [kalenderwo] => 
    [preis] => 
    [input_submit_6] => Submit
    [70ccd68aebd22acbcdf76a4e098fb2fb] => 1
)

Validation Errors:

Array
(
)

with "[kalenderwo] =>" and "[price] =>" of each value should be passed.

kalenderwo = KalenderWoche()
preis = preis_tot.toFixed(2)

But it would not work.

do you ned the Javascript and HTML Code to find it out?

Best Regards
bambid
GreyHead 25 Oct, 2013
Hi bambid,

I got it from the JavaScript Console in my web browser.

Bob
bambid 01 Nov, 2013
Hello Bob

I think i got it. i wrote with .innerHTML but i have to take .value.
Now i got another Problem. I made a Paypal link like This:
http://www.chronoengine.com/faqs/2583-how-to-use-the-paypal-redirect-action.html
It works, but the Amount field will not overgive the right value. If i Debbug with the chronoforms the "preis" will still be 10

If i try it with Paypal
"preis" is variable on every submit, like:
1. 20
2. 50
3. 20
4. 30
...

I did not change anything while i'm submit. Still the same values.

A guess?

Thanks Best Regards
bambid
GreyHead 01 Nov, 2013
Hi bambid,

The 'trial' version of the PayPal ReDirect action randomises the amount. You need the paid version to stop that happening.

If you don't need IPN (Instant Payment Notification) then using PayPal with the ReDirect URL & ReDirect User actions may work OK for you.

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