Formatting a list box

Results 1 to 2 of 2

Thread: Formatting a list box

  1. #1
    Join Date
    Dec 1969

    Default Formatting a list box

    I have a two part problem regarding setting string lengths in a listbox and speeding up the loading of a page.<BR><BR>I have a list box which pulls its data from an Access 2000 database containing around 350 records. I have populated the one list box with three different fields, ProdName, ProdCode and BatchID. This works OK in so far as the actual data output is concerned, but the formatting is pretty ordinary. Basically one field just runs into the next and forms one long string. How can I format the listbox so that ProdCode starts at position 0, ProdName at position 16 and BatchID at position 51?<BR><BR>The second part of this problem is probably the easiest. The listbox needs to be used 10 times on the one page, so it is fairly slow to load. Any ideas?

  2. #2
    Join Date
    Dec 1969

    Default RE: Formatting a list box

    Formatting a list box has to be done browser-dependent. MS and Netscape have completely different rules. Doing what you want isn&#039t terribly hard with MS, but I haven&#039t figured out how to do it in Netscape. If you need it cross-browser...good luck. If you&#039ll live with an MS-only solution:<BR><BR>&LT;HTML&#062;<BR><BR>&LT;HEAD&#0 62;<BR>&LT;STYLE&#062;<BR>SELECT.mono { font-family: courier,monospace; width: 400 }<BR>&LT;/STYLE&#062;<BR>&LT;/HEAD&#062;<BR><BR>&LT;BODY&#062;<BR>&LT;FORM&#062; <BR>&LT;SELECT class="mono"&#062;<BR>&LT;OPTION&#062;This is a demo<BR>&LT;OPTION&#062;12345678901234567890123456 7890<BR>&LT;OPTION&#062;One&AMP;nbsp;&AMP;nbsp;&AM P;nbsp;&AMP;nbsp;&AMP;nbsp;&AMP;nbsp;&AMP;nbsp;Ten &AMP;nbsp;&AMP;nbsp;&AMP;nbsp;&AMP;nbsp;&AMP;nbsp; &AMP;nbsp;Twenty<BR>&LT;/SELECT&#062;<BR>&LT;/FORM&#062;<BR>&LT;/BODY&#062;<BR>&LT;/HTML&#062;<BR><BR>See what you have to do? <BR>(1) Specify a style for the SELECT that asks for a monospaced font. Without that, you&#039ll *never* get things to line up.<BR>(2) Use spaces to "pad" your pieces out to the proper length...and then replace each space with &AMP;nbsp; (Non Breaking SPace) or it still won&#039t work!<BR><BR>********************<BR><BR>Second part:<BR><BR>Do you mean that *identically* the same listbox needs to be used 10 times? If so...<BR><BR>(1) Instead of writing the stuff from &LT;SELECT&#062; through &#060;/SELECT&#062; directly to the HTML page, put it all into a *single* string (using the &AMP; operator to concatenate it all). Then simply Response.Write that single string each of the 10 times. <BR><BR>(2) If the string is really huge, then that is obviously a less than satisfactory solution. Sending the string 10 times would still eat time, even if it is only built once. In that case, consider creating the list once via ASP and then "cloning" the list on the browser-side using JavaScript. Again, Netscape will cause problems; pre-load each of the &#060;SELECT&#062; lists with a line of spaces sufficient to ensure that any item in the list is visible when the list gets populated.<BR><BR>If this doesn&#039t get you started, ask again. Email okay.<BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts