I have little weird issue with Selectbox.js
I am converting an existing selectbox with below code
var sb = new SelectBox({
selectbox: $(this),
height: 140,
width: "100%"
});
Here $(this)
is $('#sltCountry')
like below
<select id='sltCountry' name='sltCountry'>
<option value="1">India</option>
<option value="2">USA</option>
<option value="3">UK</option>
</select>
Now what happens that I want to set selected value for $(this)
but as I have used SelectBox()
, I am not able to do that.
select box is converted into <dl>
tags. So explicitly I cannot set value for that what I want to set.
Function I am using to convert all select
boxes into SelectBox() type select boxes.
function newSelectBox(obj) {
$(obj).each(function() {
var sb = new SelectBox({
selectbox: $(this),
height: 140,
width: "100%"
});
});
}
Usage: newSelectBox($('select'));
I have spent many hours to do this but could not succeeded.
Can anyone please help me out?