Gossamer Forum
Home : Products : DBMan : Customization :

Select in default.cfg OR second db ??

Quote Reply
Select in default.cfg OR second db ??
Hi All.

I have a select field I need to add.

However, there are 225 lines (options) for them to select from.

Would you'all recommend I add those 225 lines (in a one-line-format) into the default.cfg 'select' section, or add a second database for just this 'select' field?

Also, is the latter even possible?

Can you use a second database just to draw data from?

Well... you can ignore the last few questions if you want... I really only need the first question answered!

As Always, Thanks!

------------------
John B. Abela
Owner, 4CM
www.4cm.com/
support@4cm.com

Presently working on:
http://www.4cm.com/cmp3/
Finished: http://www.humbee.com/buzz/


Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
I've used the following JavaScript for a 750+ option dynamic select field... works pretty well, but takes a while to load... (obviously Smile

http://javascript.internet.com/forms/list-chooser.html

It's one of more frequently used bookmarked JavaScript sites...

------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)

Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
Here is what I used:

Code:
|;
open(SELECT,"/cgi-bin/stations.txt")&#0124; &#0124; die "Can't open file"; @station_list = (<SELECT> );
close (SELECT);
print qq|<select name="Station Name">|;
foreach (@station_list){
chomp $_;
print qq| <option>$rec{'Station Name'}</option>|;
print "$_\n";
}
print qq|</select>

I put this into my html.pl file, then used a text file (1 option per line) and it has at last count over 1800 options. NO wait time while it lists them either.

in my CFG file I have the following under the database definition part
Code:
'Station Name' => [ 1, 'alpha', 20, 255, 1, '', ''],
Just treated as a regular text space, not as an option list. Works like a charm!


One thing to remember, the text file MUST have a blank line at the top of the text file else it will search using that name in the field. Follow me?


------------------
Conor Treacy
www.handsonwebdesign.com

Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
Very nice little mod... but you still have the UI problem... selecting from 750-- let alone 1800-- choices is not the best interface in the world.

------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)

Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
Yeah you really can't depend on the users to know exactly what you're looking for (hence my 1800 option). I needed to list where the trouble report was comming from, currently 1800 different locations are in operation. I found when trying to research what problems were fixed or not, searching for Borrego Springs some people would have Borr. Springs, or shorten springs... made my search impossible.

It's quick, it's dirty, but hey... what else ya gonna do Smile

One thing nice in the drop down is that if the user types the first letter of the station (lets say it's SANGAR), they type "S" and it jumps down the scroll list to the "s's"... Of course telling the user it can do that is another problem all together Smile

------------------
Conor Treacy
www.handsonwebdesign.com

Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
Leprechaun, I attempted to use your code, but it threw a error at me.

I was able to fix that error by bring together the two |'s on the first line.

Then, once that was working... when I loaded the page... it just showed the select field... it was long as he-he (which means it loaded the list)... however it was blank.

It didn't show anything.

Hope that makes sense.

Any suggestions?

oldmoney... I'd have gone with yours but I don't know how to interface to the JS with the html code within the html.pl file!

Later guys.

------------------
John B. Abela
Owner, 4CM
www.4cm.com/
support@4cm.com

Presently working on:
http://www.4cm.com/cmp3/
Finished: http://www.humbee.com/buzz/


Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
Well I have two things for ya:
Number 1 is that I goofed up and didn't tell you that where "/cgi-bin/stations.txt" is, that's supposed to be the full path to your file /html/sas/cgi-bin/stations.txt. OOPS!!

Also, after looking through the fourm, I found my orriginal message that was used to help solve this problem in the first place
http://www.gossamer-threads.com/...m12/HTML/001510.html

You'll notice that I didn't quite follow the directions that they suggested, but it was working the way I needed it to.

UBB puts in a space between to |'s automatically sorry. Here's a caption from that link I showed you
Code:
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Node Type:</FONT></TD>
<TD VALIGN="TOP"> |;
open(SELECT,"/path/to/list/file") | | die "Can't open file";
@node_list = (<SELECT> );
close (SELECT);
print qq|<select name="Node_type">|;
foreach (@node_list) {
chomp $_;
print "<option";
print " SELECTED" if ($rec{'Node_type'} eq "$_");
print ">$_\n";
}
print qq|</select>
</TD></TR>

You can see I deviated from what they suggested, but somehow it all came together. I'm still very new to perl, and learn more from hack & paste Smile, but even that's not learning!

Hopefully that link can help you, I haven't experienced that problem. I've modified my code tring to duplicate what you had, but nothing. I'll continue to keep an eye out for you, but at this time I don't have an answer.
Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
Yokhannan
I finally ran into the problem that you were having with the long list of blank options. It seems that that only happens in Explorer, which is unusual since normally it's Netscape that will squak at bad code! Smile

I'm going to start on it now, and should have an answer to your problem in a little bit. And I'd never have known only the company is switching everything to microsoft products!
Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
 
Quote:
And I'd never have known only the company is switching everything to microsoft products!

Even with Intranet Web applications, you should always test your web pages via the last two versions (at least) of Netscape and MIE before making them "public".

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
Ok, well I finished messing with it, and found that the only way it will show up correctly in both IE and NS is using the method chris had suggested in the first place! There's what I get for not following the rules!!

My code now looks like the folowing, and it works like a charm.

Code:
<tr><td width="68%"> |;
open(SELECT,"/html/sas/cgi-bin/stations.txt")&#0124; &#0124; die "Can't open file";
@station_list = (<SELECT> );
close (SELECT);
print qq|<select name="Station Name">|;
foreach (@station_list){
chomp $_;
print "<option";
print " SELECTED" if ($rec{'Station Name'} eq "$_");
print ">$_\n";
}
print qq|</select>
If you copy and paste this in your *.PL file, remember to move the two pipe bars together (at the die statement), UBB likes to split them.
Yokhannan, hopefully you have your code working by now, but I figured i'd post this here for the next person searching the fourm.

------------------
Conor Treacy
www.handsonwebdesign.com

Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
Hi!

Just a quick question. This mod looks like what I want as I list every country at the moment. The question is, is this suitable for a hard coded drop-down box in a header or footer? I want this to act as a 'jump to:' type menu available on all apges - so I take it I can just build it into a search form?

Could yu give me an example? I search for this field ONLY with ascending results.


------------------
Ben

-------------------------
http:/www.t-e.co.uk

Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
You can certainly create a search form on each page. Something like:

Code:
print qq|
<form action="$db_script_url" method="get">
<input type="hidden" name="db" value="$db_setup">
<input type="hidden" name="uid" value="$db_uid">|;
open(SELECT,"/html/sas/cgi-bin/stations.txt")or die "Can't open file";
@station_list = (<SELECT> );
close (SELECT);
print qq|<select name="Country">|;
foreach (@station_list){
chomp $_;
print "<option";
print " SELECTED" if ($rec{'Station Name'} eq "$_");
print ">$_\n";
}
print qq|</select>
<input type="Submit" name="view_records" value="Search></form>|;



------------------
JPD






Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
benseb:

I haven't used this method so I'm not sure exactly what it will do.

For my cooking site I use a text file to list all my recipe categories in a drop-down. I called the file recdrop.txt and the setup for the search looks this:

<form method="get" action="db.cgi">
<input type=hidden name="db" value="cook">
<input type=hidden name="uid" value="default">
<input type=hidden name="sb" value="4">
<input type=hidden name="so" value="ascend">
<input type=hidden name="view_records" value="1">
<input type=hidden name="Validate" value="Yes">
<select name="Category" size="1">
<OPTION>Choose a Category:
<option value="Appetizer">Appetizers
<option value="Assorted">Assorted Recipes
<option value="Barbecue_Grill">Barbecue & Grill
<option value="Beef">Beef
<option value="Beverage">Beverages
....
....
....
</SELECT> <INPUT TYPE="SUBMIT" NAME="view_records" VALUE="GO"></FORM>

Within my header which is in format.pl rather then directly in the html.pl file I use:

<CENTER>$site_logo<BR><BR>$site_title<BR>
<!--#include virtual="recdrop.txt"--><BR>$line</CENTER><P>

You can see an example of how this works at:
http://www.creativecomputing1.com/cooking/kitchen2.htm

This may work out for you if you are able to use SSI include statements on your server. I realize some people do not have any luck including SSI commands within scripts, but I use them all the time with no problem within my format.pl setups.

If you are not familiar with the format.pl file it is something which is mentioned in JPDeni's user friendly html. It takes out the global formatting from the main script and puts it all into a separate .pl or .cgi file.
Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
I have the Country field set as a normal text field as stated previously, and select_fields rem'ed out, as for Leprechaun's mod.

UNFORTUNATELY, I just get a blank field for Country. I have added the coding below for html_record_form:
Code:
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Country:</FONT></TD>

<TD VALIGN="TOP"> |;
open(SELECT,"/home/travel/cgi-bin/countries.txt") | | die "Can't open file";
@Country_list = (<SELECT> );
close (SELECT);
print qq|<select name="Country"><option>|;
foreach (@Country_list) {
chomp $_;
print "<option";
print " SELECTED" if ($rec{'Country'} eq "$_");
print ">$_\n";
}
print qq|</select>
</TD></TR>

Any ideas why I can't see my countries? The Countries field is appearing as a text box NOT a list box.

PS &#0124; &#0124; has no space before you ask!
------------------
Ben

-------------------------
http:/www.t-e.co.uk



[This message has been edited by benseb (edited April 13, 2000).]
Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
Anyone?
Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
The reason I didn't respond before was that the code you have uses a different kind of syntax than I usually use, so I don't really understand what it's doing.

If it was me, I'd use the "build_select_field_from_db" structure so that you will know your visitors will actually get search results when they use the list. But that's just me. Smile


------------------
JPD






Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
Fair point for the hardcoding into the header, but this should be able to be used for Modify/Add/Delete as well because it lists the possible choices from a text file. If not I would have to add all 255 choices to default.cfg .... which leads back to the original question... which is quickest? This way it only loads the listings when required.

But does anyone know how to fix it!!?


------------------
Ben

-------------------------
http:/www.t-e.co.uk

Quote Reply
Re: Select in default.cfg OR second db ?? In reply to
ben, two things I've been thinking about last night, one is if you try to define the width of the field. right now we're letting it build it on it's own, but if you put in width="100" or "200" does that let you see the items when they drop down.

The other is the fact that you said that it's a text box rather than a drop down. As long as the select and option statements are in there, it should be drop down.

Another item I noticed when i viewed my own page source is that each of the options are <option>Station name
<option>next station
<option>next station

there's no closing tags for option. This should be throwing up errors all over the place but it's still running. I added the /option line which would fix that.
Code:
print " SELECTED" if ($rec{'Station Name'} eq "$_");
print ">$_</option>\n";

I don't have access to IE here at work (stictly netscape) so I can't even test anything for you. I've put a copy of the program on disk to take home tonight so i can fiddle with it a little more at home.

As for your orriginal question "which is quickest"... all i can say to that is NO IDEA. Although I think we all know which one is WORKING
Smile


------------------
Conor Treacy
www.handsonwebdesign.com



[This message has been edited by Leprechaun (edited April 17, 2000).]