Reputation: 2821
I'm working on a smarty template. I cannot edit the PHP code as it is encoded.
I have an order form where clients view their total due, fill-in their personal information, and then complete payment.
Items on my website are taxable for the United States and each state has different rate.
My system does not allow dynamic tax rate calculation based on user's selection to the state, but it provides a (Tax Update) button where users manually click on it to update the tax rate.
I'm trying to improve that and make it behave like dynamic.
I need to auto trigger a click on that (Tax Update) button each time the user select a state or switch between them. For example, if the user select Kansas, it will auto click that button so the user won't have to press it. Same thing if he selected Kansas and then changed it to Kentucky for example.
At the end, I will hide that button using display:none;
Sample HTML:
<select id="selectstate" name="state">
<option value="Alabama">Alabama</option>
<option value="Kansas">Kansas</option>
<option value="Kentucky">Kentucky</option>
</select>
<input type="submit" value="Tax Update" name="update" />
Can anyone help with a JavaScript or jQuery code to achieve this? I need the (Tax Update) button to be auto-clicked whenever selecting a state or selection changes. Any answer is appreciated.
Upvotes: 1
Views: 2837
Reputation:
Just it:
$('#selectstate').on('change', function(){
$("[name='update']:submit").trigger("click");
});
If you can, use an id to your submit button
Upvotes: 2