Hello,
Sorry in advance for my ignorance. I've tried different javascript code in various places and also read some of the FAQs but I can not get it to work.
The scenario: a tuition payment form. the student can select nationality ->school->program. (I have each dropdown populating the next dropdown using the events tab of the dropdown). I also have the option for students to select up to three courses that they can pay for individually.
Based on the entire program or up to three individual courses the tuition needs to be calculated and displayed in a texbox.
Thanks in advance for your help
Sorry in advance for my ignorance. I've tried different javascript code in various places and also read some of the FAQs but I can not get it to work.
The scenario: a tuition payment form. the student can select nationality ->school->program. (I have each dropdown populating the next dropdown using the events tab of the dropdown). I also have the option for students to select up to three courses that they can pay for individually.
Based on the entire program or up to three individual courses the tuition needs to be calculated and displayed in a texbox.
Thanks in advance for your help
Hi philomenacato,
You'd do this using Custom JavaScript - hard to say more from the information you have posted.
Which version of ChronoForms are you using?
Bob
You'd do this using Custom JavaScript - hard to say more from the information you have posted.
Which version of ChronoForms are you using?
Bob
Sorry i left that out. I'm using v5 and joomla 3.7
Hi philomenacato,
Then use Custom JavaScript in a Load JavaScript action in the form On Load event. You will want it to run when any of the three drop-downs changes and it should then add up the three values or show a blank if any of them are not selected.
You need to get the values from somewhere - that can be taken from the values in the drop-downs; or from Javascript arrays; or from the server using an Ajax call.
Bob
Then use Custom JavaScript in a Load JavaScript action in the form On Load event. You will want it to run when any of the three drop-downs changes and it should then add up the three values or show a blank if any of them are not selected.
You need to get the values from somewhere - that can be taken from the values in the drop-downs; or from Javascript arrays; or from the server using an Ajax call.
Bob
thank you for the info. How an I assign a value to the drop down item is it placed in the options list in the events tab (I do not have a database with items)
I have it listed at this
12000=Agriculture & Food Science
1258.58=ACCA Accounting=Accounting
I have it listed at this
12000=Agriculture & Food Science
1258.58=ACCA Accounting=Accounting
Hi philomenacato ,
I'm not clear what that data is - you are only allowed one = sign in each line of the Options box. You can do something like this
Bob
I'm not clear what that data is - you are only allowed one = sign in each line of the Options box. You can do something like this
Agriculture#12000.00=Agriculture & Food Science
Accounting#1258.58=ACCA Accounting
Bob
This is my newbie status showing. I will try it and get back to you
I tried what you recommended. I decided to send pics cause I believe I have made a mess of this.
The data are courses/programs and tuition associated with them. The student must select their program and the cost must be calculated based on their nationality and course selected.[attachment=100488_20170618030902_issues-pdf.pdf][/attachment]
The data are courses/programs and tuition associated with them. The student must select their program and the cost must be calculated based on their nationality and course selected.[attachment=100488_20170618030902_issues-pdf.pdf][/attachment]
Hi philomenacato,
The code looks as if it might work OK. Is the function called? What errors are you seeing?
Bob
The code looks as if it might work OK. Is the function called? What errors are you seeing?
Bob
The function is called DoMath(). I'm not seeing any errors but the value is not showing up in the textbox
so I made some progress. There is data showing up but its saying NAN.
I believe the reason nothing was showing up was because i typed in Function instead of function. Ive attached my new issue which is that the option is not passing a the cost of the selection hence the NAN.
[attachment=100488_20170618153822_issues-pdf.pdf][/attachment]
I believe the reason nothing was showing up was because i typed in Function instead of function. Ive attached my new issue which is that the option is not passing a the cost of the selection hence the NAN.
[attachment=100488_20170618153822_issues-pdf.pdf][/attachment]
Hi philomenacato,
You have parseInt('Programme') in your code - as 'Programme' is a text string NAN is probably the correct value. You need to get the selected value of the dropdown instead.
Bob
You have parseInt('Programme') in your code - as 'Programme' is a text string NAN is probably the correct value. You need to get the selected value of the dropdown instead.
Bob
Hello Greyhead,
Thanks for being an ear. I see the error of my ways and changed the code to
function DoMath()
{
var sum = parseInt(document.getElementById('Programme').value);
document.getElementById('total').value = parseInt(sum);
}
It works fine now. The value is showing up in the text. Now on to the next step. which I'm sure I'll be making a new post with questions.
Thanks for being an ear. I see the error of my ways and changed the code to
function DoMath()
{
var sum = parseInt(document.getElementById('Programme').value);
document.getElementById('total').value = parseInt(sum);
}
It works fine now. The value is showing up in the text. Now on to the next step. which I'm sure I'll be making a new post with questions.
This topic is locked and no more replies can be posted.