Hi,
I am not a js programmer, but I found a script example for counting fields of my form.
In the form it is possible to add the names of max 6 people.
All of these people can select an other membership. So the prise is different.
At the end of the form the visitor will press the submit button.
At the "thank you" message I wil show the total amount of the 6 fields.
I have placed this script in the on load event:
At the end of the script, the amount is ready as 'bedrag'.
But when I show {bedrag} in the message text, only {bedrag} is shown in the text.
What can I do to show the amount the vistor have to pay in the message text?
I am not a js programmer, but I found a script example for counting fields of my form.
In the form it is possible to add the names of max 6 people.
All of these people can select an other membership. So the prise is different.
At the end of the form the visitor will press the submit button.
At the "thank you" message I wil show the total amount of the 6 fields.
I have placed this script in the on load event:
window.addEvent('domready', function() {
function startCalc(){
//interval = setInterval("calc()",1);
calc();
}
function calc(){
if (document.getElementById){
een = document.getElementById('abo_keuze01').value;
twee = document.getElementById('abo_keuze02').value;
drie = document.getElementById('abo_keuze03').value;
vier = document.getElementById('abo_keuze04').value;
vijf = document.getElementById('abo_keuze05').value;
zes = document.getElementById('abo_keuze06').value;
document.getElementById('bedrag').value = (een * 1) + (twee * 1) + (drie * 1) + (vier * 1) + (vijf * 1) + (zes * 1);
}
}
function stopCalc(){
clearInterval(interval);
}
});
At the end of the script, the amount is ready as 'bedrag'.
But when I show {bedrag} in the message text, only {bedrag} is shown in the text.
What can I do to show the amount the vistor have to pay in the message text?
Thanks for the automatic answer.
But that's not what I was asking for.
I hope a human forummember can help me. 🙂
But that's not what I was asking for.
I hope a human forummember can help me. 🙂
Hi Wouter,
As this code is written it will only run once when the page is loaded so there will be no values set and the value will probably be zero.
I also don't understand why you are multiplying the values by 1 ???
Please post a link to the form so I can take a quick look.
Bob
As this code is written it will only run once when the page is loaded so there will be no values set and the value will probably be zero.
I also don't understand why you are multiplying the values by 1 ???
Please post a link to the form so I can take a quick look.
Bob
Bob,
This is the form:
http://nieuweakker.nl/index.php?option=com_chronoforms5&chronoform=inschrijfformulier
As I wrote I have no experience with javascript.
I found an example which was counting the values, so I used that for this form.
It would be great when you can If you can advise me a better script.
This is the form:
http://nieuweakker.nl/index.php?option=com_chronoforms5&chronoform=inschrijfformulier
As I wrote I have no experience with javascript.
I found an example which was counting the values, so I used that for this form.
It would be great when you can If you can advise me a better script.
Hi Wouter,
The code should be rewritten to be triggered on the change event of any of the fields referenced:
Regards,
Max
The code should be rewritten to be triggered on the change event of any of the fields referenced:
$("#field_id").on("change", function(){
//run calc
});
Regards,
Max
Hi Max,
Thanks for your support.
Which code should be rewritten and is that for every field?
Can you help me little more?
It is my first experience with js, so I hope I can learn to write my own script.
For it is a bit dificult to see the solution.
Thanks for your support.
Which code should be rewritten and is that for every field?
Can you help me little more?
It is my first experience with js, so I hope I can learn to write my own script.
For it is a bit dificult to see the solution.
Try this code, but JS coding requires testing and debugging, so I can't be sure that it will work:
window.addEvent('domready', function() {
function calc(){
if (document.getElementById){
een = document.getElementById('abo_keuze01').value;
twee = document.getElementById('abo_keuze02').value;
drie = document.getElementById('abo_keuze03').value;
vier = document.getElementById('abo_keuze04').value;
vijf = document.getElementById('abo_keuze05').value;
zes = document.getElementById('abo_keuze06').value;
document.getElementById('bedrag').value = (een * 1) + (twee * 1) + (drie * 1) + (vier * 1) + (vijf * 1) + (zes * 1);
}
}
$("#abo_keuze01").on("change", function(){
calc();
});
});
Thanks,
I have added the code to the Load JavaScript in the Setup event.
My form is a little bit changed now, so at page 3 I hope to see the calculated amount which is called by {bedrag}.
But I still see the text and not that calculated amount.
I have added a backup of the form here.
So I hope someone can help to fix this.
I have added the code to the Load JavaScript in the Setup event.
My form is a little bit changed now, so at page 3 I hope to see the calculated amount which is called by {bedrag}.
But I still see the text and not that calculated amount.
I have added a backup of the form here.
So I hope someone can help to fix this.
Hi Wouter,
Please get help from someone with some coding experience. The whole purpose of using JavaScript is to get an immediate result when the user changes something in the form. The form you have uploaded here has nothing that can be changed on page 3. With this design you can do a calculation in PHP when Page 2 is submitted - or possibly with JavaScript in Page 2.
Bob
Please get help from someone with some coding experience. The whole purpose of using JavaScript is to get an immediate result when the user changes something in the form. The form you have uploaded here has nothing that can be changed on page 3. With this design you can do a calculation in PHP when Page 2 is submitted - or possibly with JavaScript in Page 2.
Bob
This topic is locked and no more replies can be posted.