javascript - Value to configure without having to submit a form with change function -


i have checkout page trying configure tax with. simple tax amount. if lives in ohio value 1.065 , if in other state in nothing.

i'm not best @ using javascript php, may why having difficulties. trying configure without submitting form. when customer has click drop down box select state, want configure then. not submitting form until later in page , want them see value right away.

i start having list of arrays of states this..

$taxvalue['ohio'] = 1.065; $taxvalue['wyoming'] = 1; 

then making variable tax amounts:

$taxed_state = 1.065; $untaxed_state = 1; 

then i'm checking if state set , adding taxed variable it.

if(isset($taxvalue['ohio'])){             $taxed_state;        } else {          $untaxed_state;     } 

this how i'm going configure total tax.

   $base_price = 0;             foreach($_session['shopping_cart'] $id => $product) {                 $product_id = $product['product_id'];                 $base_price += $products[$product_id]['price'] * $product['quantity'];                 $shipping_price += $products[$product_id]['shippingprice'] * $product['quantity'];               }             $tax_price += $base_price * $taxed_state;             $total_price += $base_price + $shipping_price + $tax_price; 

the tax rate displayed here, i'm having issues tax rate not showing here. i'm not sure if coding right tax , total correct.

<p>tax: <span class="floatright"><?php echo "$" . $tax_price //- $base_price; 

the form when entering state:

<label for="state">state</label>         <select type="text" class="mediuminputbar preview" id="shiptostate" data-copy="#confirmstate" name="shiptostate" required>             <option value=''>select state</option>                 <?php                 foreach($taxvalue $key => $val) {                     echo "<option value='$val'>$key</option>/n";                 }                    ?>         </select> 

the javascript trying use it:

$(document).ready(function() { $(function() {     var taxed_state = 0;     var base_total = 0;      $( "#taxvalue" ).change(function() {         if ($(this).val() == 'ohio') {             taxed_state = 1.065;         }         else {             taxed_state = 1;         }         $('#taxed_price').val(base_total * taxed_state);     }); }); }); 

i'm not sure why isn't working or i'm doing wrong. have ideas?


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -