I am trying to customize the walkthrough for Tax (http://gravityhelp.com/documentation/page/Gravity_Forms_Pricing:_Adding_Tax).
But in my case, I want the tax rate to vary based on a preselected item from a dropdown list.
So for example
if you selected option 1 from the specified dropdown, then ur tax rate is X%, if you selected 2, your rate will be Y% etc.
How do I use/call up the value/item in the selected field? What filter/function/code can I use to acieve this?
See part of what I have so far in my functions.php
add_filter('gform_pre_render_3', 'add_total_script');
function add_total_script($form) {
?>
<script type="text/javascript">
function gform_product_total(formId, total){
var rate = 0;
if ($(".ginput_3_20 option:selected").text()) == "Option1_selected"){
rate = 20; } else {
if ...................................// an so on
} else {
rate = 100;
} //end if
var tax = ((rate * total) / 100); //calculate the tax to be paid and add below;
return total + tax;
}
</script>
<?php
return $form;
}