RyanSmith Posted January 11, 2005 Posted January 11, 2005 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.
Rob123 Posted January 11, 2005 Posted January 11, 2005 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
RyanSmith Posted January 11, 2005 Author Posted January 11, 2005 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 <{POST_SNAPBACK}> 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.
Rob123 Posted January 11, 2005 Posted January 11, 2005 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. <{POST_SNAPBACK}> 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
RyanSmith Posted January 11, 2005 Author Posted January 11, 2005 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 <{POST_SNAPBACK}> 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.
Rob123 Posted January 12, 2005 Posted January 12, 2005 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
RyanSmith Posted January 12, 2005 Author Posted January 12, 2005 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 <{POST_SNAPBACK}> 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.
Rob123 Posted January 12, 2005 Posted January 12, 2005 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 <{POST_SNAPBACK}> Off the top of my head, courier font is fixed-width and is available on most platforms. Robert
RyanSmith Posted January 12, 2005 Author Posted January 12, 2005 Off the top of my head, courier font is fixed-width and is available on most platforms. Robert <{POST_SNAPBACK}> 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.
Rob123 Posted January 12, 2005 Posted January 12, 2005 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. <{POST_SNAPBACK}> 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
Recommended Posts
Archived
This topic is now archived and is closed to further replies.