Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Tabs in a select list


RyanSmith

Recommended Posts

Posted

I have a drop down list <select> in my HTML. The list holds values for city and date. I want to format it so that the city is in a new column and the date is also in a neat column. Does anyone know how to do this???

 

Thanks

osCommerce is a great piece of software with wonderful contributions.

Spend some time in the contribution area. There are a lot of gems there.

Posted

This is more of an HTML question rather than osCommerce, but I'll give you my hack.

 

To make neat columns is quite a challenge within a drop down (list) box if you have variable size fields. My quick and dirty solution is to make all of your dates the same size by padding zeros. This way your city "column" will be nice and neat.

 

<select name="DateState">
<option value="0">Pick one</option>
<option value="1">01/20/05 - New York City</option>
<option value="2">10/06/05 - London</option>
<option value="3">11/01/05 - Paris</option>
</select>

HTH,

Robert

 

 

Edit: Time for spellcheck

Posted
This is more of an HTML question rather than osCommerce, but I'll give you my hack.

 

To make neat columns is quite a challenge within a drop down (list) box if you have variable size fields. My quick and dirty solution is to make all of your dates the same size by padding zeros. This way your city "column" will be nice and neat.

 

<select name="DateState">
<option value="0">Pick one</option>
<option value="1">01/20/05 - New York City</option>
<option value="2">10/06/05 - London</option>
<option value="3">11/01/05 - Paris</option>
</select>

HTH,

Robert

Edit: Time for spellcheck

 

Thanks, but thats not going to work because the values are pulled dynamically, and I need to have the city be the first item. Plus the date isn't going to be formatted that way.

 

But thanks anyway.

osCommerce is a great piece of software with wonderful contributions.

Spend some time in the contribution area. There are a lot of gems there.

Posted
Thanks, but thats not going to work because the values are pulled dynamically, and I need to have the city be the first item.  Plus the date isn't going to be formatted that way.

 

But thanks anyway.

I didn't realize that it was going to be dynamic and you wanted the city first

 

Let me assume that you are retreiving two columns from a select query.

The first column is city (with a variable len up to 20 ) and the second is date.

 

In your loop, you can determine the length of each city field.

You print the city, the padding (20 - city len) and then the date.

 

Let me know if this makes sense or you need a concrete example.

HTH,

Robert

Posted
I didn't realize that it was going to be dynamic and you wanted the city first

 

Let me assume that you are retreiving two columns from a select query.

The first column is city (with a variable len up to 20 ) and the second is date.

 

In your loop, you can determine the length of each city field.

You print the city, the padding (20 - city len) and then the date.

 

Let me know if this makes sense or you need a concrete example.

HTH,

Robert

 

Ya actually that's the path that I'm going down. I still don't have it quite right though. my code looks like:

 

function nthcs_space_fill($my_string) {

$spaces;

while ( strlen($my_string) < 30) {

$my_string .= ' ';

$spaces .= ' ';

}

return $my_string . $spaces;

}

 

But it's still not quite right. Any further suggestions would be great.

Thanks again

osCommerce is a great piece of software with wonderful contributions.

Spend some time in the contribution area. There are a lot of gems there.

Posted

Ah... if you would have asked for a function that pads spaces, I could have done that earlier today. :rolleyes:

function nthcs_space_fill($mystring = '', $maxwidth = '30'){
$mystring .= str_repeat(" ", $maxwidth - strlen($mystring));
return $mystring;
}

 

As you can see the function defaults to a length of 30 spaces.

It will output 30 spaces if no parameters are passed.

Replace   with anything you want to be repeated.

 

There may be other ways of doing this but my solutions works. (probably :-")

HTH,

Robert

Posted
Ah... if you would have asked for a function that pads spaces, I could have done that earlier today.  :rolleyes:

function nthcs_space_fill($mystring = '', $maxwidth = '30'){
$mystring .= str_repeat(" ", $maxwidth - strlen($mystring));
return $mystring;
}

 

As you can see the function defaults to a length of 30 spaces.

It will output 30 spaces if no parameters are passed.

Replace   with anything you want to be repeated.

 

There may be other ways of doing this but my solutions works. (probably  :-")

HTH,

Robert

 

One more problem. I don't think that this is working because the select list is using a variable width font. Do you know if there is a style that I can set to have the select list use a fixed width font???

 

Thanks again

osCommerce is a great piece of software with wonderful contributions.

Spend some time in the contribution area. There are a lot of gems there.

Posted
One more problem.  I don't think that this is working because the select list is using a variable width font.  Do you know if there is a style that I can set to have the select list use a fixed width font???

 

Thanks again

Off the top of my head, courier font is fixed-width and is available on most platforms.

 

Robert

Posted
Off the top of my head, courier font is fixed-width and is available on most platforms.

 

Robert

 

Ya, thats what I ended up using. It's so damn ugly though, the designers are going to have a fit about it. Oh well I guess, function before form is what I always say.

osCommerce is a great piece of software with wonderful contributions.

Spend some time in the contribution area. There are a lot of gems there.

Posted
Ya,  thats what I ended up using.  It's so damn ugly though, the designers are going to have a fit about it.  Oh well I guess, function before form is what I always say.

There's other possibly better looking fixed-width fonts that you can use.

Courier simply provided a "proof of concept". You would need to Google a little to find them.

 

Robert

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...