Hey guys,
I want to build in some realtime calculation in my form, but I am having some problems.
First I tried it by the instructions in this post: http://chronoengine.com/forums.html?cont=posts&f=2&t=66188&p=266323&hilit=calculation#p266323
It worked, except for the part to add up two values: value box 1 + value box 2 = total was this: 100 + 20 = 10020
Because I needed something more complex with dropdown and checkbox I read this tutorial:
http://www.javascript-coder.com/javascript-form/javascript-calculator-script.phtml
I got it working with Custom Forms HTML code.
Now I want to integrate it with a form build with Wizard Forms HTML code. This is what I got:
My Wizard Forms HTML code is this:
Javascript:
Problem is it's not displaying the value in the textbox with id 'prijs'.
With var theForm I've tried document.ChronoContact["Vacatureformulier"] and document.ChronoContact_Vacatureformulier and document.forms["Vacatureformulier"] but it is not working.
Help is much appreciated!
I want to build in some realtime calculation in my form, but I am having some problems.
First I tried it by the instructions in this post: http://chronoengine.com/forums.html?cont=posts&f=2&t=66188&p=266323&hilit=calculation#p266323
It worked, except for the part to add up two values: value box 1 + value box 2 = total was this: 100 + 20 = 10020
Because I needed something more complex with dropdown and checkbox I read this tutorial:
http://www.javascript-coder.com/javascript-form/javascript-calculator-script.phtml
I got it working with Custom Forms HTML code.
Now I want to integrate it with a form build with Wizard Forms HTML code. This is what I got:
My Wizard Forms HTML code is this:
<div class="ccms_form_element cfdiv_select" id="pakket_container_div">
<label for="pakket">Vacaturepakket *</label>
<select size="1" id="pakket" class=" validate['required']" title="" name="pakket">
<option value="">Kies een pakket</option>
<option value="Basic">Basic (€ 100,00)</option>
<option value="Medium">Medium (€ 320,00)</option>
<option value="Premium">Premium (€ 1050,00)</option>
<option value="Ultimate">Ultimate (€ 1800,00)</option>
</select>
</div>
<div class="ccms_form_element cfdiv_checkbox" id="opvallend_container_div">
<input value="20" id="opvallend" title="" type="checkbox" name="opvallend" class="label_left" />
<label for="opvallend">Vacatures opvallend weergeven?</label>
</div>
<div class="ccms_form_element cfdiv_text" id="prijs_container_div">
<label for="prijs">Prijs</label>
<input id="prijs" maxlength="150" size="30" class="" title="" type="text" value="" name="prijs" />
</div>
Javascript:
window.addEvent('domready', function()
{
$('pakket').addEvent('change', berekenTotaal);
$('opvallend').addEvent('change', berekenTotaal);
}
);
//Dropdown value's to prices
var pakket_prijzen= new Array();
pakket_prijzen["Basic"]=100;
pakket_prijzen["Medium"]=320;
pakket_prijzen["Premium"]=1050;
pakket_prijzen["Ultimate"]=1800;
//Calculate PakketPrijs
function getPakketPrijs()
{
var PakketPrijs=0;
var theForm = document.ChronoContact["Vacatureformulier"];
var selectedPakket = theForm.elements["pakket"];
PakketPrijs = pakket_prijzen[selectedPakket.value];
return PakketPrijs;
}
//Calculate OpvallendPrijs
function getOpvallendPrijs()
{
var OpvallendPrijs=0;
var theForm = document.ChronoContact["Vacatureformulier"];
var OpvallendPlaatsen = theForm.elements["opvallend"];
if(opvallend.checked==true)
{
OpvallendPrijs=20;
}
return OpvallendPrijs;
}
//Calculate Total
function berekenTotaal()
{
var TotaalPrijs = getPakketPrijs() + getOpvallendPrijs();
$('prijs').value = "Pakket totaalprijs is €"+TotaalPrijs;
}
Problem is it's not displaying the value in the textbox with id 'prijs'.
With var theForm I've tried document.ChronoContact["Vacatureformulier"] and document.ChronoContact_Vacatureformulier and document.forms["Vacatureformulier"] but it is not working.
Help is much appreciated!