web2py View : Height (size) of a select box in
In web2py, I wish to render a select box with size="3" sothat it will display 3 items (instead of default size 1) ~~~The code, if tested in a standalone html file, works correct (the size is 3)
{{extend 'layout.html'}}
<h1>ABC</h1>
<FORM name="drop_list" method="POST">
<table>
<tr>
<td><select id="List1" name="ABC" size="3"></select></td>
<td><input type="button" id="addtype" value="Add to List"></td>
</tr>
<tr>
<td><select id="List2" name="selABC" size="3"></select></td>
</tr>
</table>
</form>
<script language="javascript">
function addOption(selectbox,text,value)
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
function addOption_list(selectbox){
var ctg = JSON.parse('{{=XML(ctg_list)}}');
for (var i=0; i < ctg.length; ++i){
addOption(document.drop_list.ABC, ctg[i], ctg[i]);
}
}
window.onload = addOption_list;
</script>
<script>
$('#addtype').click(function(){
var index=document.getElementById("List1").selectedIndex;
var elOpt = document.getElementById("List1").options[index];
var elSel = document.getElementById("List2");
var elOptNew = document.createElement("option");
elOptNew.text = elOpt.text;
elOptNew.value = elOpt.value;
try {
elSel.add(elOptNew, null);} // standards compliant doesnt work in IE
catch(ex) {
elSel.add(elOptNew);} // IE only
})
</script>
In web2py view, its height(size) remains unaltered (1). It displays a tiny scrollbar though.
Any tip as to why my code i开发者_Go百科n web2py "View" is not able to override the default size of 1?
Thanks, Vineet
精彩评论