facebook option list selectedIndex not working
Hy I have t his script:
<script>
function get(obj) {
return document.getElementById(obj);
}
function getCrer(sel) {
var value = get(sel).options[get(sel).selectedIndex].value;
get('cbt').value=value;
}
</script>
<select id="combo1" onchange="getCrer(this)">
<option value="">Select</option>
<option value=0>Text1</option>
<option 开发者_JAVA技巧value=5>Text2</option>
<option value=9>Text3</option>
</select>
<input name="cbt" type="text" id="cbt"/>
I like to work in facebook so when I select from the list the calue shoul go to the input text cbt...but not working in fb. why?
When your onchange event fires, it's passing in the Select Object to getCrer, not the Object's ID, so your get method will return null. Try this instead:
function getCrer(sel) {
var value = sel.options[sel.selectedIndex].value;
get('cbt').value=value;
}
精彩评论