After submitting the form return to render HTML page, SELECT control value and selectedIndex property can make a drop-down box retains the state before the form is submitted.

 


code is as follows:


<SELECT id="idState" style="width: 150" name="state" selectedIndex="$! {state}" > <The option value="" > All </option> <The OPTION value="http://www.jb51.net//web/1" > Through </option> <The OPTION value="http://www.jb51.net//web/2" > At the end of the pass </option> <The OPTION value="http://www.jb51.net//web/3" > Pending </option> </select> A temporary solution is at the end of the vm file with a script for a drop-down box assignment:

 


code is as follows:


<Script> $(' # idState). Val (' $! {state} '); </script> Another solution is to set the default selected item:

 


code is as follows:


<SELECT id="idState" style="width: 150" name="state" value="http://www.jb51.net//web/$! {state}" > <The option value="" > All </option> <The OPTION value="http://www.jb51.net//web/1" > Through </option> <The OPTION value="http://www.jb51.net//web/2" SELECTED> At the end of the pass </option> <The OPTION value="http://www.jb51.net//web/3" > Pending </option> </select> Written using VTL is:

 


code is as follows:


<SELECT id="idState" style="width: 150" name="state" value="http://www.jb51.net//web/$! {state}" > <The option value="" > All </option> <OPTION # if ($! {state}==1) SELECTED # end value="http://www.jb51.net//web/1" > Through </option> <OPTION # if ($! {state}==2) SELECTED # end value="http://www.jb51.net//web/2" > At the end of the pass </option> <OPTION # if ($! {state}==3) SELECTED # end value="http://www.jb51.net//web/3" > Pending </option> </select> To note here is that the==comparison, when the Velocity is to distinguish the types of, if use the string &other; 1 &throughout; , &other 2 &throughout; , &other 3 &throughout; Comparison will always be false. , problems of velocity in comparison for velocity, especially involves the range comparison (greater than or less than) are relatively difficult to achieve. Now I want to put on the page file size classification display (Bytes, MB, GB), and then comes to compare filesize size problem, now I would like to ask about if there is any better way to achieve? For example the following code:

 


code is as follows:


# if ($filesize > 1024 & & $filesize <1048567) # set ($ksize=$filesize % 1024) <Div class="MLT >" The File Size: $ksize KB # elseif ($filesize > 1048567 & & $filesize <1073731824) # set ($msize=$filesize % 1048567) <Div class="MLT >" The File Size: $msize MB # elseif ($filesize > 1073731824) # ($gsize=$filesize % 1073731824) <Div class="MLT >" The File Size: $# else gsize GB <Div class="MLT >" The File Size: $filesize Bytes # end

 


code is as follows:


<The PRE class=HTML name="code" > <SPAN style="the font-family: Arial, Helvetica, sans-serif" > <SPAN style="WHITE - SPACE: normal" > </span> </span> </PRE> <PRE> </PRE> <PRE> </PRE> <PRE> </PRE># 0 - #


This concludes the body part