Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spacing format in drop down list

Status
Not open for further replies.
Nov 28, 2002
121
US
My drop down list is going to look like this in HTML


8000 abc project
8098 dbei anotherproject
8983 ehisfegb newproject
4323 dsd thisproject


*************************************
Problem arises when I try to space the 3rd column. It doesn't line up when I try to pad spaces. Mine is turning out like this

8000 abc project
8098 dbei anotherproject
8983 ehisfegb newproject
4323 ds thisproject


The above is incorrect.
I've done this in JSP within a loop. "project" is a variable that holds a value of the 2nd field above.
I have the below in a loop with a new "project" each time.
*************************************
int project_length = project.length();
int nSpace_amount = 12-project_length;
for (int x=0; x <= nSpace_amount; x++)
{
out.println("&nbsp;");
}
************************************
What can I do? The spacing is not doing what I want it to do.





 
Your problem is that, by default, <select> boxes use a variable-width font, so you can't easily work out how many spaces you need to line the other columns up.

One solution would be to change the font with CSS:
Code:
select { font-family: "Courier New", Courier, monospaced }
be warned, though, that some browsers might not apply font rules to select boxes.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
It doesn't work still. I'm using IE6. This is what I have:
*************************************************
out.println("<select { font-family: 'Courier New', Courier, monospaced } SIZE='1' NAME='ListBoxURL' ONChange='formHandler(this)'><option VALUE = 'NO SELECTION' selected>NO SELECTION</option>");

 
That's CSS, not HTML. The best place to put it is in a seperate style sheet, but if you have to do it inline...
Code:
out.println("<select style='font-family: \"Courier New\", Courier, monospaced' SIZE='1' NAME='ListBoxURL' ONChange='formHandler(this)'><option VALUE = 'NO SELECTION' selected>NO SELECTION</option>");
\" might not be the right way to hide the double quotes from JSP, but you can figure that out.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top