Jump to content
Server Maintenance This Week. ×

dropdown and search field


This topic is 7255 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have two fields, a dropdown with 1,2,3,4. The next field is a text field then a search button. What I want to do is if 1 is chosen search database 1 for the entered text, if 2 search database 2, etc.

Any thoughts on how to capture the drop down then do the search depending on it's value?

Thanks,

Ricardo

Link to comment
Share on other sites

You will need a search script in each of your 4 files.

In the file with dropdown make it a global number field. Make the text search field a global text field.

Your script would be a series of IF statements.

If g_File = 1

Perform script in file 1

Else

If g_File = 2

Perform script in file 1

etc.

You and use a constant relationship to pass the text field to the other files.

Link to comment
Share on other sites

That's what Ralph meant: You need to pass the search string in the text field to the related files first to be able to do the search. In your main file you can't search directly in these files, you can only call the appropriate search scripts there. In FM6 you need to build first the actual find script in the related files, which you can afterwards call from the main file.

To do this, you must first pass the entered search string to these files. If the the text field in the main file is a global field you can pass its content values to the files 1

Link to comment
Share on other sites

Well ricardito, Ralph and Detlev have given you some really bogus advice.

Don't use ScriptMaker, it is not necessary and, unless you are me, you will have problems since CDML does not in and of itself recognize when a ScriptMaker event failure occurs. ScriptMaker is single-threaded and does not queue near-simultaneous requests. Yes, I know that ScriptMaker is used by IWP (this is the CDML forum not the IWP forum, which means you are doing a custom web solution), but I doubt than anyone who has used ScriptMaker in IWP has tested their scripts rigorously against near-simultaneous requests as multiple submissions. And without the experience of such rigorous testing they give advice.

Further, don't use Globals in web publishing. The web is a stateless medium. Globals can be changed by another user.

Make your dropdown part of your form action. Refer to your copy of the CDMLRdb and the FMP-Option tag.

Good luck.

Link to comment
Share on other sites

RE: Make your dropdown part of your form action. Refer to your copy of the CDMLRdb and the FMP-Option tag.

Hi, ricardito! I was about to suggest JavaScript since I assumed this dropdown was on the first web page visitors see? If so, I'm not sure the [FMP-option] will work for you since I think it is processed AFTER you have already queried your db somehow... you cannot use [FMP-...] tags until after Web Companion has been tickled. Unfortunately, I don't know JavaScript well enough to help you, but I think I remember seeing something in the posts about querying 2 different databases depending upon what a user selects. You may want to search for that thread and see if it helps.

Keith Davie is the Script-Over-the-Web man and knows his stuff, so it's good that you heed his script warning... I did and do. (ok, admittedly I used a script over the web but it was a generic house-cleaning script that had nothing to do with the web form in question, so I figured it was safe enough wink.gif ).

--ST

Link to comment
Share on other sites

Try this:

<select name="myfield1">

<option value="">Select a Value</option>

<option......

</select>

Enter text: <input type="text" name="myfield2" value="">

By default if a field's input is blank a seach will not be performed on that field. You can use some Javascript that prevents values for both fields from being submitted.

All the best.

Garry

Link to comment
Share on other sites

Hi,

Steve is correct, the first field, the dropdown, is not part of the FM database.

What I want to do is to have this field with the options 1, 2, 3 or 4.

After this is chosen then enter in the second field, a FM db field, the name of the person (Smith as an example).

Then on clicking on the search button check the first field and if it's 1 then search in 1 db for Smith, if 2, etc.

The question is how to grab that first field that is not a field in the database and from it decide which database to search.

Or am I going about this the wrong way?

Link to comment
Share on other sites

Hi, again! I'm not as knowledgeable as Keith or Garry and don't know JavaScript. What you want... "...to grab that first field... decide which database to search" cannot be done in CDML since CDML works AFTER the form is submitted. However, JavaScript allows you to do a little scripting and functionality BEFORE the form is submitted... e.g. JS can be used to validate that fields have not been left blank and/or are of the appropraite type, etc.

If it were my project, I would probably make 1 page with the dropdown that the user selects which would auto-launch a URL with the appropriate database and then have a search box on that second page. What you want can be done on the 1st page, but you'll need more than CDML to do it.

--ST

Link to comment
Share on other sites

Right now I have several forms, each with it's own format file.

So the first one is for db 1 and it passes a token and goes to format file 1.html.

The second form passes token to format file 2.html.

What I'm trying to do is to not have 4 different fields on the web page. Instead of it saying

Enter text: (FMP Field) Search-button for db 1 search

Enter text: (FMP Field) Search-button for db 2 search

etc.

I want to have the dropdown with 1,2,3 and 4

Dropdown (FMP Field) Search-button

But not sure how to get it to go to different format files from here.

Thanks,

Ricardito

Link to comment
Share on other sites

Hi, Ricardito! Have you tried Garry's suggestion?

You can do this:

<select name="-db">

<option value="mydb1.fp5">Select DB1</option>

<option value="mydb2.fp5">Select DB2</option>

<option......

</select>

I just did, and it worked great. (Garry, sorry you had to tell us twice!) I didn't realize FMP can accept a -db (or other) object/property in other forms. It'd probably work for letting users choose their own -format pages, too. It's a neat trick, GC, thanx.

<option value="detail.html">Detailed View</option>

<option value="short.html">Summarized View</option>

--ST

Link to comment
Share on other sites

This topic is 7255 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.