Calculation script |
Post Reply ![]() |
Page 12> |
Author | |
sevens ![]() Newbie ![]() ![]() Joined: Nov 25 2020 Location: Namibia Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() Posted: Nov 25 2020 at 8:43pm |
Hi, need help with a calculation on a page, no scripting knowledge or where and how to place such script in OE. I have 4 elements on a page as follows: dropdown list with id: combo_primertext input field with id: edit_primer_width text input field with id: edit_primer_height text input field with id: edit_primer_qty_calc I want to calculate as follows when a key is pressed in any one of the text input fields, or an item is selected in the dropdown list: if combo_primer items 1 is selected then edit_primer_qty_calc.value = roundup (edit_primer_width.value * edit_primer_height.value) / 3.6 if anyone can assist in detail, thank you |
|
Riaan S
|
|
![]() |
|
Hobby001 ![]() Admin Group ![]() ![]() Joined: Jun 05 2018 Location: Canada, Québec Status: Offline Points: 5975 |
![]() ![]() ![]() ![]() ![]() |
Hi, |
|
![]() |
|
Hobby001 ![]() Admin Group ![]() ![]() Joined: Jun 05 2018 Location: Canada, Québec Status: Offline Points: 5975 |
![]() ![]() ![]() ![]() ![]() |
What do you want to do with the calculated result? Display it on the page?
Ok, I saw it in yout text input field list Edited by Hobby001 - Nov 25 2020 at 9:22pm |
|
![]() |
|
sevens ![]() Newbie ![]() ![]() Joined: Nov 25 2020 Location: Namibia Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() |
Hi Hobby001,
The url to the page: http://nomax.group/Paint%20Calculator.htm Thanks, Riaan
|
|
Riaan S
|
|
![]() |
|
sevens ![]() Newbie ![]() ![]() Joined: Nov 25 2020 Location: Namibia Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() |
Yes,
Want to display the calculated result in the text input field with id: edit_primer_qty_calc, to the far right I see it is currently -4 in Quebec, isshhh. Would love to be able to immigrate to Canada. Thanks, Riaan
|
|
Riaan S
|
|
![]() |
|
Hobby001 ![]() Admin Group ![]() ![]() Joined: Jun 05 2018 Location: Canada, Québec Status: Offline Points: 5975 |
![]() ![]() ![]() ![]() ![]() |
I will come back to you as soon as I have a minute. It should be today or tomorow.
Meanwhile may I suggest that you take a look at these tutorials: https://forum.openelement.com/en/forum_posts.asp?TID=1714&title=tutorial-responsive-or-not Edited by Hobby001 - Nov 25 2020 at 9:32pm |
|
![]() |
|
Hobby001 ![]() Admin Group ![]() ![]() Joined: Jun 05 2018 Location: Canada, Québec Status: Offline Points: 5975 |
![]() ![]() ![]() ![]() ![]() |
Ok, here is the code:
If width or hight = 0, nothing will happend since there is no sense dividing 0 by 3.6 Edited by Hobby001 - Nov 25 2020 at 10:31pm |
|
![]() |
|
Hobby001 ![]() Admin Group ![]() ![]() Joined: Jun 05 2018 Location: Canada, Québec Status: Offline Points: 5975 |
![]() ![]() ![]() ![]() ![]() |
You have to add a javascript code block in EndBody position to your page and insert this code into it
|
|
![]() |
|
sevens ![]() Newbie ![]() ![]() Joined: Nov 25 2020 Location: Namibia Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() |
Thank you so much for your help, works 100%, appreciated.
How do I trigger the same calculation for any key press in the edit_primer_width & edit_primer_height edit boxes?
|
|
Riaan S
|
|
![]() |
|
Hobby001 ![]() Admin Group ![]() ![]() Joined: Jun 05 2018 Location: Canada, Québec Status: Offline Points: 5975 |
![]() ![]() ![]() ![]() ![]() |
First add a custom class named Chosen_Fields to your two size input fields
You may also check the read-only check box for your WEedit_primer_qty_calc field Edited by Hobby001 - Nov 26 2020 at 8:06am |
|
![]() |
Post Reply ![]() |
Page 12> |
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |