Reputation: 3254
Following code is working with Firefox browser but onClick is not working with Chrome and Safari.
Is there anything missing in the following code. If anyone can help so that It can work with cross browser.
Thanks.
<html><body><form method="post">
<select>
<option value="aa">Please select</option>
<option value="pst" onClick="populate();">Select Existing State</option>
</select>
<select name="abc" id="example-select" style="width: 160px;"></select>
</form>
<script type="text/javascript" language="javascript">
var example_array = {state1 : '1# First State', state2 : '2# Secondstate', state3 : '3# Third State'};
function populate() {
var select = document.getElementById("example-select");
for(index in example_array) {
select.options[select.options.length] = new Option(example_array[index], index);
}
}
</script>
</body></html>
Upvotes: 0
Views: 253