×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

tabs in a dropdown (select - option)

tabs in a dropdown (select - option)

tabs in a dropdown (select - option)

(OP)
Hello,

I have a dropdown menu that I fill up with some data (ID, store, article):

5 - Store A - Article 1
6 - Store ABCDEF - Article 2
7 - Store ZBC - Article 3

You see, this is not so nice, I want something like:

5 Store A      Article 1
6 Store ABCDEF Article 2
7 Store ZBC    Article 3

Is this possible? If not, someone an idea how I could do something simmular but in a different way?

visit my website at http://www.phpscriptor.com

RE: tabs in a dropdown (select - option)

Hi

Quite ugly solution :

CODE

option {
  font-family: monospace;
  white-space: pre;
}
No idea why, the white-space was overridden in My FireFox, so I had to add !important.

Feherke.
http://rootshell.be/~feherke/

RE: tabs in a dropdown (select - option)

(OP)
hmm I see my code didn't show right. This is what I want:

CODE

5 Store A      Article 1
6 Store ABCDEF Article 2
7 Store ZBC    Article 3

Anyway, I tried your sollution and that didn't work...

visit my website at http://www.phpscriptor.com

RE: tabs in a dropdown (select - option)


Really? It works for me in Fx2.

Note: in Fx2, unless you style the select element in the same way, only the 'dropped down' list will show like you want, rather than the 'dropped down' list and the collapsed view.

Dan

 

Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page @ Code Couch
http://www.codecouch.com/dan/


 

RE: tabs in a dropdown (select - option)

Hi

Correct. Styling the option does not affect the select neither in FireFox 3 . I did not included select in the style because I supposed that such formatting is meaningful only if more than one row of data is visible.

Feherke.
http://rootshell.be/~feherke/

RE: tabs in a dropdown (select - option)

(OP)

CODE

var recordlist = document.getElementById('dropdown');
for(var i=0; i<data.results.length; i++) {
  var newOpt = document.createElement('option');
  newOpt.value = data.results[i]['ID'];
  newOpt.text = data.results[i]['name'];
  recordlist.options.add(newOpt);
}

So, it's not working? Another problem is that it has to be done with javascript smile. And it needs to work with IE. My company only works with IE so...

visit my website at http://www.phpscriptor.com

RE: tabs in a dropdown (select - option)


Aaah - you have to make sure you are using NBSPs instead of normal spaces for IE. My test harness did, and it worked:

CODE

<html>
<head>
    <style type="text/css">
        select,
        option {
            font-family: monospace;
            white-space: pre;
        }
    </style>
</head>

<body>
    <form>
        <select>
            <option>An item&nbsp;&nbsp;&nbsp;001 ABC</option>
            <option>Yet more!&nbsp;002 ABC</option>
            <option>Again&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;003 ABC</option>
        </select>
    </form>
</body>
</html>

Dan

 

Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page @ Code Couch
http://www.codecouch.com/dan/


 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close