abperfecto
asked on
Jquery script to take select option and make API call with parameter
Hi,
I have a html select drop down with a list of countries.
Want I need is for when I select a country, it takes the value and envokes a call to my webapp 'search/city.view?value={s elect box value}' which then populates an empty city select drop down.
Im using jQuery JavaScript Library v1.3.1 - I know it's out dated but its used throughout the site at the moment and to change would be time consuming at the moment, there is plans to down the line.
Many thanks
I have a html select drop down with a list of countries.
Want I need is for when I select a country, it takes the value and envokes a call to my webapp 'search/city.view?value={s
Im using jQuery JavaScript Library v1.3.1 - I know it's out dated but its used throughout the site at the moment and to change would be time consuming at the moment, there is plans to down the line.
Many thanks
What format is the data returned by your city.view script?
ASKER
This is an example...
<?xml version="1.0" encoding="UTF-8"?>
<list lang="en" datalang="en" countrycode="AU">
<item value="0">Please select</item>
<item value="ADL">Adelaide</item >
<item value="EPZ">Alexandra Headland</item>
<item value="ASP">Alice Springs</item>
<item value="EPV">Apollo Bay</item>
<item value="AYQ">Ayers Rock</item>
<item value="BNE">Brisbane</item >
<item value="BME">Broome</item>
<item value="QYN">Byron Bay</item>
<item value="CNS">Cairns</item>
<item value="CUD">Caloundra</ite m>
<item value="CBR">Canberra</item >
<item value="DRW">Darwin</item>
<item value="EXW">Dunsborough</i tem>
<item value="EXZ">Fraser Island</item>
<item value="OOL">Gold Coast</item>
<item value="EYJ">Halls Gap</item>
<item value="HVB">Hervey Bay</item>
<item value="HBA">Hobart</item>
<item value="KNX">Kununurra</ite m>
<item value="LST">Launceston</it em>
<item value="FFG">Lorne</item>
<item value="FGP">Magnetic Island</item>
<item value="MEL">Melbourne</ite m>
<item value="MJK">Monkey Mia</item>
<item value="PER">Perth</item>
<item value="PTI">Port Douglas</item>
<item value="RTS">Rottnest Island</item>
<item value="FKU">Scarborough</i tem>
<item value="MCY">Sunshine Coast</item>
<item value="SYD">Sydney</item>
<item value="TMW">Tamworth</item >
<item value="GZC">Whitsundays</i tem>
</list>
<?xml version="1.0" encoding="UTF-8"?>
<list lang="en" datalang="en" countrycode="AU">
<item value="0">Please select</item>
<item value="ADL">Adelaide</item
<item value="EPZ">Alexandra Headland</item>
<item value="ASP">Alice Springs</item>
<item value="EPV">Apollo Bay</item>
<item value="AYQ">Ayers Rock</item>
<item value="BNE">Brisbane</item
<item value="BME">Broome</item>
<item value="QYN">Byron Bay</item>
<item value="CNS">Cairns</item>
<item value="CUD">Caloundra</ite
<item value="CBR">Canberra</item
<item value="DRW">Darwin</item>
<item value="EXW">Dunsborough</i
<item value="EXZ">Fraser Island</item>
<item value="OOL">Gold Coast</item>
<item value="EYJ">Halls Gap</item>
<item value="HVB">Hervey Bay</item>
<item value="HBA">Hobart</item>
<item value="KNX">Kununurra</ite
<item value="LST">Launceston</it
<item value="FFG">Lorne</item>
<item value="FGP">Magnetic Island</item>
<item value="MEL">Melbourne</ite
<item value="MJK">Monkey Mia</item>
<item value="PER">Perth</item>
<item value="PTI">Port Douglas</item>
<item value="RTS">Rottnest Island</item>
<item value="FKU">Scarborough</i
<item value="MCY">Sunshine Coast</item>
<item value="SYD">Sydney</item>
<item value="TMW">Tamworth</item
<item value="GZC">Whitsundays</i
</list>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry Chris,
Our answers seem to have crossed over, the main difference between the two is that my code doesn't assume that the city select is empty.
Jon
Our answers seem to have crossed over, the main difference between the two is that my code doesn't assume that the city select is empty.
Jon
No worries - often happens.
I think it's fair to assume that's the way to do it though :)
I think it's fair to assume that's the way to do it though :)
ASKER
Many thanks to both of you for your time and thought.
If you had selects of id country and city then the following might work:
Open in new window
if search/city.view?value=UK returned the following html:
Open in new window