Skip to content

Instantly share code, notes, and snippets.

@speedmax
Created September 11, 2009 09:44
Show Gist options
  • Save speedmax/185196 to your computer and use it in GitHub Desktop.
Save speedmax/185196 to your computer and use it in GitHub Desktop.
<select id="country">
<optoin>Australia</option>
<option>China</option>
</select>
<select id="city">
</select>
<script>
var cities = {
"China": ["Hong Kong", "Beijing"],
"Australia", ["Sydney", "Melbourn"]
}
$('#country').change(function(){
$('#city').html('')
$.each(cities[this.value], function(city) {
$('#city').append('<option>' + city +'</optoin>')
})
})
</script>
<select id="country">
<optoin>Australia</option>
<option>China</option>
</select>
<select id="city">
</select>
<script>
var cities = {
"China": ["Hong Kong", "Beijing"],
"Australia", ["Sydney", "Melbourn"]
}
$('country').observe('change', function(){
$('city').setHtml('');
cities[this.value].each(function(city) {
$('city').append(new Element('option', text: city))
})
})
</script>
@argenisosorio
Copy link

argenisosorio commented Aug 3, 2019

<optoin>Australia</option> is <option>Australia</option>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment