Created
September 11, 2009 09:44
-
-
Save speedmax/185196 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
<optoin>Australia</option>
is<option>Australia</option>