Your html:
<select id="estadosiniciales">
<option value ="sydney">Sydney</option>
<option value ="melbourne">Melbourne</option>
<option value ="cromwell" selected>Cromwell</option>
<option value ="queenstown">Queenstown</option>
</select>
Your Javascript:
var newOption = new Option("newStateName","newStateName");
var selectIni = $("#estadosiniciales"); // using Jquery
selectIni.append(newOption)
Resources:
http://www.devguru.com/technologies/ecmascript/quickref/option.html
http://stackoverflow.com/questions/4647863/trouble-dynamically-adding-options-to-select
<select id="estadosiniciales">
<option value ="sydney">Sydney</option>
<option value ="melbourne">Melbourne</option>
<option value ="cromwell" selected>Cromwell</option>
<option value ="queenstown">Queenstown</option>
</select>
Your Javascript:
var newOption = new Option("newStateName","newStateName");
var selectIni = $("#estadosiniciales"); // using Jquery
selectIni.append(newOption)
Resources:
http://www.devguru.com/technologies/ecmascript/quickref/option.html
http://stackoverflow.com/questions/4647863/trouble-dynamically-adding-options-to-select
No comments:
Post a Comment