Gossamer Forum
Home : Products : DBMan : Customization :

Drop Down Menu Size

Quote Reply
Drop Down Menu Size
Hi all...this is the first time I have begun trying to use the "Build Feature" in DBman ...I am having problems getting DBman to set the drop down menu size using the "formlenght" setting in the config file...it should set according to the input in the "formlenght" setting right?... that is how you set it right? or is just by the content input in the %db_select_fields?? ..any help would be appreciated...thanks Rob

field_name => ['position', 'field_type', 'formlength', 'maxlength', 'not_null', 'default', 'valid_expr']

Quote Reply
Re: Drop Down Menu Size In reply to
When you say size, do you mean the size="X" attribute of the select list?

If so, then this is not set by the "formlength" field unfortunately, but it could easily be edited in.

Open up db.cgi and find the sub build_select_field { sub-routine.

Now find the following green line, and add the red code:
$output = qq|<SELECT NAME="$column" size="$db_form_len{$column}"><OPTION>---|;

That should do it.

- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: Drop Down Menu Size In reply to
Hi Astro-Boy...thanks for the input....the code you provided expands the depth of the menu...what I what is to set the width of the dropdown menu field..got any ideas on the this..thanks Rob

Quote Reply
Re: Drop Down Menu Size In reply to
Ahh I see.

Unfortunately you cannot set the width of a select list. It will always be as wide as your longest option.

- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: Drop Down Menu Size In reply to
Of course, (going off what Astro said) you could just make the default setting a row of dashes or mundane characters the total length of what you want the field to be then it would be your longest field no matter what... then again...if you were hoping to make the dropdown box smaller, I have no clue. =/

Quote Reply
Re: Drop Down Menu Size In reply to
I am having some problems with a select field, too.
I need a drop down list of every country in the world. This makes a very long comma separated entry in the cfg file.
What is the restriction on "max length" in the field configs, if any.
Every time I try something new I get the error message "Bad name after Zimbabwe' at .... then the path and line number of the config file at that point.
If I reduce the number of items in the list, all is well.
I assume there is an absolute limit on the number of options that can be offered.
Can anyone comment, please.


David Olley
Anglo & Foreign International Limited,
http://www.afil.co.uk
Quote Reply
Re: Drop Down Menu Size In reply to
David, not sure about the max length thing, but I'd check to make sure your not using some weird character (like an umlauf or something) in one of the country names that is causing it to freak out.

If it turns out to be a max length issue you could try "hard coding" the select field instead of using the &build_select function. To keep from getting the data over-ridden I do the following:

<SELECT NAME="$rec{'Country'}">
<OPTION>$rec{'Country'}
<OPTION>option 1
<OPTION>option 2
</SELECT>

<EDIT>
6-22-01: above s/b NAME="Country" - my bad.
</EDIT>

Then in your default value in the cfg file you can put "Choose One" or " -- " or "Country" to make it obvious for your end users. This way what ever they choose will show (because option = $rec{''}) when they come back to modify the record. This should get that long string of text out of your cfg file and place it into your html.pl file. I don't know if it will make a difference in performance or not. Try it - if it doesn't work you can always change it back.

Later, Mike.

Ps: out of curiosity... how many countries do you have listed?

Quote Reply
Re: Drop Down Menu Size In reply to
Thanks for the suggestion Mike.

Maybe I am not using the code you suggested correctly, but it does not work.

My list contains 241 Countries (believe it or not). The cfg string is rather long!

There has to be a way of doing this, but it seems to be upsetting the script and returning illogical error statements. My code certainly works with a MUCH shorter list, so I am having to assume it is the sheer size of the list that is the problem.

Where are Alex and Elliott when you need them? :-)


David Olley
Anglo & Foreign International Limited,
http://www.afil.co.uk
Quote Reply
Re: Drop Down Menu Size In reply to
Ooops! Try this:

<SELECT NAME="Country">
<OPTION>$rec{'Country'}
<OPTION>option 1
<OPTION>option 2
</SELECT>

The previous example had a typo - this is what I get for not checking a working example.

This *should* work if placed in the proper spot in html.pl under: sub html_record_form and under: sub html_record

Make sure you have "Country" in default.cfg set up like the following:
'BOR State' => [6, 'alpha', 0, 255, 0, 'TX', ''],

Assuming your not using autogenerate (which I don't think you are) - it should work, however, I'd like to see a solution that was a little less rudimentary.

Quote Reply
Re: Drop Down Menu Size In reply to
You should be in the habit of using value attributes in drop-down menus since earlier versions of Mosaic and AOL do not support drop-down menus without VALUE attributes...also, using end tags for the OPTION anchors is wise as well, since some browsers do not support SELECT menus without them.

Like the following:

Code:

<SELECT NAME="Country">
<OPTION VALUE="$rec{'Country'}">$rec{'Country'}</OPTION>
<OPTION VALUE="option 1">option 1</OPTION>
<OPTION VALUE="option 2">option 2</OPTION>
</SELECT>


Regards,

Eliot Lee
Quote Reply
Re: Drop Down Menu Size In reply to
Using Excel as a brilliant formatting tool, I now have all 240 odd countries in a drop down list that works perfectly.
Much thanks to the helpers, and especially Eliot who came in with the essential reminder about attributes.
I assume that dbman, or perl, has an inbuilt limit to the length of line that can be used for the field.
Is this true Eliot? Does anyone know what that limit is, in bytes (or characters), for future reference?


David Olley
Anglo & Foreign International Limited,
http://www.afil.co.uk