Happy new year!
I have been using earlier versions of Joomla and various Chronoforms containing a javascript that validates and does pricing calculations. This is triggared by clicking a "calculate" button to run the script.
I have just upgraded to Joomla 1.7 and Cf 4 RC 3.0. Using the wizard a have added a button called "Calculate Price" as follows: <button onClick="DoQuotation(this.form.name)" style="color: red" ><b>Calculate total price</b></button>.
The javascript is:
---------------------------
Clicking the "Calclate Price" button correctly runs the javascript (from Firebug):
However immediately after completing the script, it "submits" the form when it should not do so until the user is happy and has clicked the "submit" button. The form contents are emailed when they should not be. This causes a new blank page to be loaded (this will become a "thank you" page in due course).
Page URL:
http://friendsoftherail.com/joomla/index.php?option=com_chronoforms&chronoform=Booking_Cullinan
which gets automatically replaced by:
http://friendsoftherail.com/joomla/index.php?option=com_chronoforms&chronoform=Booking_Cullinan&event=submit
Question: How do I stop this unwanted automatic execution of the "submit" event after running the javascript?
Many thanks, Steve A
I have been using earlier versions of Joomla and various Chronoforms containing a javascript that validates and does pricing calculations. This is triggared by clicking a "calculate" button to run the script.
I have just upgraded to Joomla 1.7 and Cf 4 RC 3.0. Using the wizard a have added a button called "Calculate Price" as follows: <button onClick="DoQuotation(this.form.name)" style="color: red" ><b>Calculate total price</b></button>.
The javascript is:
function DoQuotation(formName)
{
var tradult;
var fareadult;
if ( document.forms[formName].NAdult.value == "")
{tradult = 0;
fareadult = 0;}
else
{tradult = parseInt(document.forms[formName].NAdult.value);
tradult = Number(tradult);
fareadult = tradult*175;}
.
.(snip)
.
farenett = faregross - farediscount;
pricetotal = farenett + priceoptions;
faregross = faregross.toFixed(2);
farediscount = farediscount.toFixed(2);
farenett = farenett.toFixed(2);
priceoptions = priceoptions.toFixed(2);
pricetotal = pricetotal.toFixed(2);
document.forms[formName].totalpass.value = totalpax;
document.forms[formName].payingpass.value = payingpax;
document.forms[formName].grossfare.value = "R " + faregross;
document.forms[formName].nettfare.value = "R " + farenett;
document.forms[formName].options.value = "R " + priceoptions;
document.forms[formName].total.value = "R " + pricetotal;
document.forms[formName].discount.value = "-R " + farediscount;
updatecookie(document.forms[formName]);
quoted = true;
return true;
}
---------------------------
Clicking the "Calclate Price" button correctly runs the javascript (from Firebug):
function onclick(event) {
DoQuotation(this.form.name);
}
However immediately after completing the script, it "submits" the form when it should not do so until the user is happy and has clicked the "submit" button. The form contents are emailed when they should not be. This causes a new blank page to be loaded (this will become a "thank you" page in due course).
Page URL:
http://friendsoftherail.com/joomla/index.php?option=com_chronoforms&chronoform=Booking_Cullinan
which gets automatically replaced by:
http://friendsoftherail.com/joomla/index.php?option=com_chronoforms&chronoform=Booking_Cullinan&event=submit
Question: How do I stop this unwanted automatic execution of the "submit" event after running the javascript?
Many thanks, Steve A