Solved

SELECT format columns

Posted on 2002-05-28
12
195 Views
Last Modified: 2010-04-09
I have a SELECT listbox on a form that contains names and addresses. How can I make the address start at the same position/column ?

In VB I would put a tab character in the text, but I can't see anything like.

I'm using VB Webclasses to output the html stream. I could use a grid control, but it looks heavy going to format the grid each time.

Any suggestions ?

TIA

John

0
Comment
Question by:JohnHind
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
12 Comments
 
LVL 18

Expert Comment

by:bruno
ID: 7039456
Don't think you can do what you are trying to do all within the same SELECT...

can we see a code snippet?


BRUNO
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 7039872
JohnHind,
What do you mean? Doesn't make sense.

You want to position a couple of elements at the same place? What elements?

You might be able to use layers and position them above each other.

I don't really get what you want. Tell us more.

CJ
0
 
LVL 18

Expert Comment

by:bruno
ID: 7039967
CJ,

I think I can remember something similar creating forms in Access...

you can show more than one value, almost like a select with different columns to it...


BRUNO
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:CJ_S
ID: 7039993
Oh that! :-)

try using the \t operand instead of a normal tab :-)

"\tblah"
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7040073
when you say "position/column", you mean identation, probably using whitespace left of text?
Then simple answer: not possible
     long answer: any method like using \t or %09 is not reliable, means it might work with a special browser of paricular version on uniq OS etc. etc.
IMHO, even using CSS is vasting time, unfortunately.

The only reliable method I know is to use printable characters, like a dash: -
0
 

Author Comment

by:JohnHind
ID: 7040117
Here's the snippet. Basically, I need to change the commas for tabs, so I get columns - ie the addresses line up. Sounds like I can't do it.

<SELECT align=center id=lstMain size=20 name=lstMain style="WIDTH: 80%; HEIGHT: 60%"><option>Fred Smith, 1 The High Street, Nottingham<option>Joe Public, 2 Smith Street, Birmingham</SELECT>

John
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 7040118
separate your columns with pipe symbols (|) and then convert the pipes to a pre-determined number of spaces like this:


<HTML>
<HEAD>
<SCRIPT language='javascript'>

 function padOptions(theSelect,L)
 {
   L = L||20;  // 20 by default, if L is not specified
   for ( var i=0,n=theSelect.options.length; i<n; i++ )
   {
      var ta = theSelect.options[i].text.split("|");
      for ( j=0,m=ta.length; j<m; j++ )
      {
         var D = L - ta[j].length;
         for ( var k=0; k<D; k++)
            ta[j] += " ";
      }
      theSelect.options[i].text = ta.join("");
   }

 }

</script>
</head>

<BODY onLoad='padOptions(document.myform.myselect,20);'>

<FORM name='myform'>
 <FONT face='courier new'>
 <SELECT name='myselect' style='font:9pt courier new;'>
  <OPTION>col1|col2</option>
  <OPTION>column1|column2</option>
  <OPTION>This Is Column1|This Is Column2</option>
 </select>
 </font>
</form>

</body>
</html>


(I tested this in IE5+ and NS6 ... I doubt it will work in NS4)
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 7040121
Sorry, I didn't see your last post until after I posted ... if you want to use commas instead, then change this:

   var ta = theSelect.options[i].text.split("|");

to this:

   var ta = theSelect.options[i].text.split(",");
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 7040123
also note the fixed-face font ... this is necessary.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 7040136
You can also use the &nbsp; character to indicate 1 space. Works in most cases.

0
 
LVL 33

Accepted Solution

by:
knightEknight earned 250 total points
ID: 7040166
yeah, I tried that, but when you set it using javascript, it actually shows the &nbsp; in the select ... which is what lead me to use a regular space instead.  But, if you want to "pad" the options from the server (instead of using the javascript function) then you would have to use the &nbsp;

Also, for your data, you will probably want to use a number bigger than 20 (which I used) to pad your data columns.
0
 

Author Comment

by:JohnHind
ID: 7040303
I'll give that a go.

thanks
John
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
BG appearing and then disappaear after a second 8 62
Html using "Or" in condition 3 43
Anchor Bookmark 6 34
SSL unsecure page mystery 17 47
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question