Note that there are some explanatory texts on larger screens.

plurals
  1. POweb2py View : Height (size) of a select box in
    primarykey
    data
    text
    <p>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)</p> <pre><code>{{extend 'layout.html'}} &lt;h1&gt;ABC&lt;/h1&gt; &lt;FORM name="drop_list" method="POST"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;select id="List1" name="ABC" size="3"&gt;&lt;/select&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="button" id="addtype" value="Add to List"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;select id="List2" name="selABC" size="3"&gt;&lt;/select&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;script language="javascript"&gt; 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 &lt; ctg.length; ++i){ addOption(document.drop_list.ABC, ctg[i], ctg[i]); } } window.onload = addOption_list; &lt;/script&gt; &lt;script&gt; $('#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 }) &lt;/script&gt; </code></pre> <p>In web2py view, its height(size) remains unaltered (1). It displays a tiny scrollbar though.</p> <p>Any tip as to why my code in web2py "View" is not able to override the default size of 1?</p> <p>Thanks, Vineet</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload