Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create a new option and inject into select box using mootools 1.2

i have one AJAX function which return the list of countries. It works fine.

My problem is that want to load that countries in on select box which is already in HTML and is empty means no option value in it.

I want to know that how can i create a new option element and inject into the select box using moo tools 1.2

I have used below code but its not working in IE.

var NewOption = new Option("Select Sub Category",'0');

NewOption.inject($('nSub_nIndustryID'))

Thanks

Avinash

like image 531
Avinash Avatar asked Feb 20 '10 03:02

Avinash


2 Answers

There is no need to create a variable, unless you are going to use it later.

new Element('option', {'value': 0, 'text':'Select states first'}).inject($('sCity'));
like image 136
javi Avatar answered Nov 06 '22 18:11

javi


i have solved it my self..

var newElement =  new Element('option');    
newElement.inject($('sCity'));
newElement.setProperty('value','0');
newElement.appendText('Select States first');

Thx for your time....

like image 33
Avinash Avatar answered Nov 06 '22 19:11

Avinash