ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

Setting another element onchange

hcharris 08 Aug, 2018
This should be a simple problem but I'm not finding the answer on my own. I'm running chronoforms5 on Joomla 3.8.11 . I have a simple form that is getting two fields from the _users database and displaying them on the form correctly. I also have two other fields on the form: a drop-down where one selects a 1, 2, or 3 and a total field. What I want to happen is if a 1 is selected the total field value is changed to 25.00, if a 2 is selected the total field value is changed to 50.00, and if a 3 is selected the total field value is changed to 75.00. The total field is not shown (parent hidden) until the numeric field is selected.

I think I should be able to set the value in the event tab of the total field but so far I have not had any success.

Any assistance would be appreciated.

Screenshot_from_2018-08-07_20-35-17.png
hcharris 08 Aug, 2018
Update:
I did not understand and have taken a different route.

1. Added a Load Javascript in Setup: function settotal() {this.form.elements["total"].value = '25.00'; }
2. In Designer, I have added the following in Events tab:
capture.png
3. A test of the form, gives me the following html:
<script type="text/javascript">function settotal() {this.form.elements["total"].value = '25.00';
}</script>
and
function chronoforms_fields_events(){$("[name='dropdown9']").on("change", function(){if($("[name='dropdown9']").val() == "1"){if($("#fin-total, #total").closest(".gcore-subinput-container").length > 0){ $("#fin-total, #total").closest(".gcore-subinput-container").css("display", ""); }else if($("#fin-total, #total").closest(".gcore-form-row").length > 0){ $("#fin-total, #total").closest(".gcore-form-row").css("display", ""); }}}); $(':input[name="dropdown9"]').on('change', function(){ settotal()($(this)); });}

I think this is progress but the field value is not being updated when the field in the dropdown changes.

Again, I appreciate any help.
hcharris 09 Aug, 2018
Answer
After several hours of trying , I was able to get this working.
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com