Stupid Form Tricks - Many Select Boxes, So Little Code
for most browsers
Here's a way to save on code when you need one or more selects that contain large lists of items.
Create an Array for each select
you'll need. Each item in the array represents one <option> (
'value | text' ).
Then call the function passing the name of the select and the name of the
array you want displayed.
When hard-coded, the example below created a 14.5 kb file.
Using the javascript method, the file size was only 6.5 kb.
That's a savings of over 50%! What a bargain!
<script> var site_status = new Array('|All Sites','F|Currently on the Final NPL',...); // - This has been edited. Do a 'view source' to see all the arrays. function putSelects(name,n){ document.write('<select name="'+name+'" size="1">'); for (i=0; i<n.length; i++){ n[i] = n[i].split('|') document.write('<option value="'+n[i][0]+'">'+n[i][1]+'</option>'); } document.write('</select>'); } </script> <script> putSelects('site_status',site_status); </script>
PXL8 2003