Hi, my apologies if this has been answered eslewhere but I cannot find such an answer.
I have used the following in CF v4-RC3, Joomla 2.5.38 which has been working well:
Now I am porting the site to Jommla 3.3.6, CF v5.0.8, and I cannot get this to work. The old code does not work when pasted into CFv5. I have changed it to use simply "this.form" and, in deperation, inserted a bit of test code as below. The debugging console says "this.form" is undefined. Hence the alert message displays only "Undefined" and not the form's ID. Every piece of documentation and wisdom I can find says that "this.form" should contain the current form object, yet it seems it does not.
Where am I going wrong? All help would be appreciated. Many thanks, Steve.
I have used the following in CF v4-RC3, Joomla 2.5.38 which has been working well:
<button onClick="DoQuotation(this.form.name)" style="color: red" type = "button"><b>Calculate total price</b></button>
<script>
... var tradult;
var fareadult;
if (document.forms[formName].NAdult.value == "")
{tradult = 0;
fareadult = 0;}
else
{tradult = parseInt(document.forms[formName].NAdult.value,10);
fareadult = tradult*250;} ...
</script>
Now I am porting the site to Jommla 3.3.6, CF v5.0.8, and I cannot get this to work. The old code does not work when pasted into CFv5. I have changed it to use simply "this.form" and, in deperation, inserted a bit of test code as below. The debugging console says "this.form" is undefined. Hence the alert message displays only "Undefined" and not the form's ID. Every piece of documentation and wisdom I can find says that "this.form" should contain the current form object, yet it seems it does not.
<input type= "button" name="doc" style="color: red" value="Doc" onClick="Showdoc(this.form)" >
<script type= "text/javascript">
function Showdoc(form)
{alert (this.form.id);
return false;}
</script>
Where am I going wrong? All help would be appreciated. Many thanks, Steve.
Problem solved. This is the code I have now used:
<input type= "button" name="quote" style="color: red" value="Calculate Price" onClick="DoQuotation(this.form)" >
<script>
function DoQuotation(form)
{ var contacts = 0;
var formid =(form.id);
var tradult;
var fareadult;
if (document.forms.namedItem(formid).NAdult.value == "")
{tradult = 0;
fareadult = 0;}
else
{tradult = parseInt(document.forms.namedItem(formid).NAdult.value,10);
fareadult = tradult*250;}
....
</script>
This topic is locked and no more replies can be posted.