snowdog Posted January 23, 2012 Share Posted January 23, 2012 Is it possible to do a jquery on change for a select box. What I am trying to do is you pick your country, then it populates the province/state box with the appropriate prov/states. Canada and USA. Thanks James Quote Link to comment https://forums.phpfreaks.com/topic/255625-jquery-onchange/ Share on other sites More sharing options...
trq Posted January 23, 2012 Share Posted January 23, 2012 Yes. $('yourselect').change(function(e) { // do something }); Quote Link to comment https://forums.phpfreaks.com/topic/255625-jquery-onchange/#findComment-1310436 Share on other sites More sharing options...
snowdog Posted January 23, 2012 Author Share Posted January 23, 2012 so here is exactly what I want to do. Maybe the oncghange is not the right thing. When they select USA, it populates the option boxes with the states and if they pick Canada it populates the provinces into the option. <p> <label for="name">Franchise Country</label> <input type="text" name="f_country" class="sf" /> </p> <p> <label for="State/Prov">State</label> <select name="f_state_prov"> <option>Choose One</option> <option value="AL">Alabama</option> <option value="AK">Alaska</option> <option value="AZ">Arizona</option> <option value="AR">Arkansas</option> <option value="CA">California</option> </select> <label for="State/Prov">Province</label> <select name="f_state_prov"> <option value="AB">Alberta</option> <option value="BC">British Columbia</option> <option value="MB">Manitoba</option> <option value="NB">New Brunswick</option> <option value="NF">New Foundland</option> <option value="NT">Northwest Territories</option> <option value="NS">Nova Scotia</option> <option value="NT">Nunavut</option> <option value="ON">Ontario</option> <option value="PI">Prince Edward Island</option> <option value="PQ">Quebec</option> <option value="SA">Saskatchewan</option> <option value="YT">Yukon Territory</option> </select> Quote Link to comment https://forums.phpfreaks.com/topic/255625-jquery-onchange/#findComment-1310442 Share on other sites More sharing options...
trq Posted January 24, 2012 Share Posted January 24, 2012 onChange is indeed correct. Have you tried to write any code? Quote Link to comment https://forums.phpfreaks.com/topic/255625-jquery-onchange/#findComment-1310496 Share on other sites More sharing options...
snowdog Posted January 24, 2012 Author Share Posted January 24, 2012 unfortunetly yes, This is my first crack at jquery and am having trouble understanding it. I understand logic flow but am having trouble with this. I have been following the examples on the jquery website and don't understand how it will know which option values to load when you change the country in the previous drop down box. James Quote Link to comment https://forums.phpfreaks.com/topic/255625-jquery-onchange/#findComment-1310524 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.