Good Day
I have these line of codes in my javascript
......
........
this will create a selectBox element named destinationCity
the scenario is this...
when i select a country with an appropriate list of cities found.. a selectbox will be created. when there is no cities listed for that country an inputbox will be created.
i am able to change back and forth with this but i could not add an attribute onChange() to the created selectBox..
is it possible for me to create an onChange() attribute to the selectbox wherein the result will be something like:
<select name="city" onchange="javas cript:myFunctio n">
i tried this but it wont work:
inputSel.setAtt ribute("onChang e","myFunction( )");
Thanks in advance
I have these line of codes in my javascript
......
Code:
if (selObj.type == 'text' ) {
parentObj = document.getElementById('destinationCity').parentNode;
parentObj.removeChild(selObj);
var inputSel = document.createElement("SELECT");
inputSel.setAttribute("name","destinationCity");
inputSel.setAttribute("id","destinationCity");
parentObj.appendChild(inputSel) ;
selObj = document.getElementById('destinationCity');
selObj.options[optionCounter++] = new Option('Select State','');
selObj.selectedIndex = 0;
}
this will create a selectBox element named destinationCity
the scenario is this...
when i select a country with an appropriate list of cities found.. a selectbox will be created. when there is no cities listed for that country an inputbox will be created.
i am able to change back and forth with this but i could not add an attribute onChange() to the created selectBox..
is it possible for me to create an onChange() attribute to the selectbox wherein the result will be something like:
<select name="city" onchange="javas cript:myFunctio n">
i tried this but it wont work:
inputSel.setAtt ribute("onChang e","myFunction( )");
Thanks in advance
Comment