Hi GreyHead,
Can you please assist me on a hidden field that will display the Total Amount when the user selects a value from the dropdown menu?
My dropdown menu has the following values : 1,2,3,Family. What I am trying to do is that when the user chooses value "1" then it will multiply to 29 and will display the amount to the hidden field and when the user chooses value "2" then it will multiply to 29 and so on, but when the user chooses the value "Family" then a fixed amount (let's say "100") will be displayed on the hidden field.
I am using the latest Chronoform version, Thanks...
Can you please assist me on a hidden field that will display the Total Amount when the user selects a value from the dropdown menu?
My dropdown menu has the following values : 1,2,3,Family. What I am trying to do is that when the user chooses value "1" then it will multiply to 29 and will display the amount to the hidden field and when the user chooses value "2" then it will multiply to 29 and so on, but when the user chooses the value "Family" then a fixed amount (let's say "100") will be displayed on the hidden field.
I am using the latest Chronoform version, Thanks...
Hi bryancd911,
Assuming that the id of the select drop-down is 'select_1' and the hidden input is 'hidden_1' this code should work in a Load JS action
Bob
Assuming that the id of the select drop-down is 'select_1' and the hidden input is 'hidden_1' this code should work in a Load JS action
window.addEvent('domready', function() {
$('select_1').addEvent('change', function() {
switch($('select_1').value) {
case 1:
case 2:
case 3:
$('hidden_1').value = 29 * parseInt($('select_1').value);
break;
case 'Family':
$('hidden_1').value = 100;
break;
}
});
});
NB Not tested and may well need debugging!Bob
Thanks for the code but can't get it to work so I tried another method. The thing is that it's not working properly. I used the dropdown menu to get a value for each option. I did it this way:
29=1
58=2
87=3
100=4
Initially, if I fill out the form, it works perfect, it picks up the value that I wanted but the problem exists after that. It gives me weird computations like if I choose option 3, it multiplies the value by 3 therefore giving me 261 as the result. Is there any other way to do this? Thanks.
29=1
58=2
87=3
100=4
Initially, if I fill out the form, it works perfect, it picks up the value that I wanted but the problem exists after that. It gives me weird computations like if I choose option 3, it multiplies the value by 3 therefore giving me 261 as the result. Is there any other way to do this? Thanks.
Hi bryancd911,
Yes there are many other ways to do it. Difficult to comment or suggest without any hard information about what the code is or what the problems are.
Bob
Yes there are many other ways to do it. Difficult to comment or suggest without any hard information about what the code is or what the problems are.
Bob
Here is a little php code that does this after the form is submitted. (goes in a custom code box in the On Submit area)
I'm sure there's a better way to write this but it works upon submit.
The select options are simply
1=1
2=2
Family=Family
Hope it helps.
<?php
if ($form->data['select'] == "1"){
$form->data{'hidden'} = $form->data['select'] * 29;
} elseif ($form->data['select'] == "2"){
$form->data{'hidden'} = $form->data['select'] * 29;
} elseif ($form->data['select'] == "Family"){
$form->data{'hidden'} = "100";
} else {
$form->data{'hidden'} = "0";
}
?>
I'm sure there's a better way to write this but it works upon submit.
The select options are simply
1=1
2=2
Family=Family
Hope it helps.
Thank You so much, you guys save my day...
This topic is locked and no more replies can be posted.