Jump to content

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

Recommended Posts

Posted

I'm new to CDML and have what I hope is a simple question.

On my form for adding a new record, for one of the fields (genus_id), I have a value list (genera) based on a related file. The related file has two fields an ID and description. I can get the ID's to pop up fine with this code:

<SELECT NAME='genus_id' SIZE=1 >

<OPTION VALUE=""> - No Selection - [FMP-VALUELIST: genus_id, LIST=genera]

<option [FMP-ValueListItem]>[FMP-VALUELISTITEM][/FMP-VALUELIST]

</SELECT>

But what I really need to pop up is the description and then store the selected ID in the new record. In the database, the value list "genera" is defined to contain both ID and Description.

Any help will be much appreciated.

Hunter

Posted

Use FMP-Portal instead of FMP-Valuelist, e.g.B)

<select name="genus_id" size="1">

<option value="">No Selection

[FMP-Portal: Related_Genera]

<option value="[FMP-Field:Related_Genera::ID]">[FMP-Field:Related_Genera::Description]

[/FMP-Portal]

</select>

Where Related_Genera is the name of the relationship your current value list is based on, and ID and Description are the two related fields in your genera database.

[Edit: forgot one detail] Be sure to include the Related_Genera portal on the FM layout!

Posted

Thanks for the replies.

Unfortunately I can't report any great break-throughs yet. Before I do that, It looks like I will either need to learn how to use portals for selecting values in related files, or how to use [FMP-InlineAction] tags for doing the same. In any case I'll need a nights sleep before starting. In the meantime, if you want to debate or elaborate the merits of your two approaches, please know it will be appreciated.

Hunter

Posted

"...if you want to debate or elaborate the merits of your two approaches..."

It is good to have solution design choices.

If you have the data and it is not currently related, you can try using the inlineaction. If that is a satisfactory solution, great. No need to develop the relationships and portals.

If it is not quite what you want and you don't have the relationships/portals, you can set that up and then experiment with that solution.

And if you have the relationships/portals already in place, then you can try both quite easily, and determine which looks best / works best / best suits the overall design of your solution.

Posted

Thanks again to all of you for your patience and guidance.

I just have a couple of conceptual hurtles to jump before I can progress.

Regarding portals, I've found them easy to set up and useful for displaying records in related files. What's confusing me here is how to use a portal as an input control for selecting a related record. I figure until I know how to do this in Filemaker itself, it would be hopeless to try and get it to work in a web-based form.

My other hurtle is how to use the [FMP-InlineAction] tag. I've browsed high and low looking for good examples of how to use this tag with a value list. I assume this tag is used inside the value list tag? Any relevant example code using this tag in some similar way to what I need (explained in the beginning of this thread) would be most welcome.

I realize there is a sometimes a fine line between getting help here and expecting others to do the work for you. At the moment, though, I feel so stuck in neutral the only useful activity I can find to do is plead for further guidance until I either have a moment of inspiration or stumble across the right example.

Hunter

Posted

Hunter,

Here is an example of how to use an InlineAction:

<SELECT NAME='genus_id' SIZE=1 >

<OPTION VALUE=""> - No Selection -

[FMP-InlineAction: -db=genusDB.fp5, -lay=mylayout, -findall]

<option value="[FMP-Field:genus_id]">[FMP-Field:description]

[/FMP-InlineAction]

</SELECT>


If the 'genus_id' field, in this file, does not have unique entries this method may not be appropriate.

Hope it helps.

Garry

Posted

Garry,

Many thanks for walking me through this. After customizing your example code, I am able to get it to work, sort of. The value list now shows the description only, and I can create a new record which stores the genus ID field correctly. The only problem is only one record is begin shown in my value list even though the database has a few hundred entries. This is the actual HTML code being generated:

<select NAME='genus_id' SIZE=1 >

<option VALUE=""> - No Selection -

<option value="13">Ruellia

</select>

In the genera database my ID's are unique so there's no problem there. I'm continuing to experiment and am optimistic I've come far enough now to keep progressing.

Hunter

Posted

Whoops! I left out the [FMP-Record] tags.

<SELECT NAME='genus_id' SIZE=1 >

<OPTION VALUE=""> - No Selection -

[FMP-InlineAction: -db=genusDB.fp5, -lay=mylayout, -findall][FMP-Record]

<option value="[FMP-Field:genus_id]">[FMP-Field:description]

[/FMP-Record][/FMP-InlineAction]

</SELECT>


This should do the job.

Garry

  • 1 year later...
  • Newbies
Posted

Hello,

I'm a cdml newbie too. I have a similar problem. I've tried the solution Garry Claridge sugested. And it works okay with the database. There's only a GUI problem. I guess because my 'Genus_id' field isn't unique.

I work with 2 tables/database files. A relations database and a company database. Those two are related by an id-key (called company_id in the relations db, id in the company db)

It comes down to this;

Relations.fp5;

-company_id (not unique)

Companies.fp5;

-id (unique)

-company_name (unique)

What I want to do is about the same as hdesport; to display a scrolldown menu in an editpage with the different company names in the value list, however selecting one should edit company_id.

As said the script shown above works, however the scrolldown menu displays company_names multiple times. This is because company_id is not unique. Is there a way to solve this problem?

Thanks in advance,

Jos.

Posted

Confused! I'm using your code above but modified to my databases:

<SELECT NAME='CustNo' SIZE=1 >

<OPTION VALUE=""> Choose a customer...

[FMP-InlineAction: -db=customers.fp5, -lay=web, -findall][FMP-Record]

<option value="[FMP-Field:CustNo]">[FMP-Field:Name]

[/FMP-Record][/FMP-InlineAction]

</SELECT>

I'm not getting any records listed in the drop down list, other than "Choose a customer..." I've made sure the proper databases are open and shared by using:

http://myURL/FMPro?-format=-fmp_xml&-dbnames. Also I've quadruple checked the spelling on the layout and field names. What am I missing?

Thanks for any help,

Mark Durgee

Posted

Is the normal syntax working?

Something like:

<SELECT name="CustNo" size="1">

<OPTION VALUE=""> Choose a customer

[FMP-valuelist:Cust,list=Cust]

<OPTION> [FMP-valuelistitem]

[/FMP-valuelist]

</SELECT>

Posted

Anatoli,

Yes that normal value list works fine. I can't get the inline action posted by Garry to work. I know I'm missing something small. Well, hopefully it's something small.

Thanks,

Mark

Posted

I tried out the inline action with stripped down test files and it worked perfectly. So I just have to figure out what's wrong with my main solution.

Now to makes things more complicated I'm trying to sort the name field alphabetically. When I do I get no names in the box. Wouldn't I just add

"-SortField=myfieldname" to the end of the inline action?

Posted

I didn't have my web security file include the customer database, so (duh!) of course it wasn't working. I also figured out the alphabetical sort by putting the -sortfield before the -findall.

One last problem... The drop down list only shows the first 25 records. How can I increase to show all customer names? This is the code I'm using:

<OPTION VALUE=""> Choose a customer...

[FMP-InlineAction: -db=Cust.fp5, -lay=web, -sortfield=Name, -findall][FMP-Record]

<option value="[FMP-Field:CustNo]">[FMP-Field:Name] - [FMP-Field:CustNo]

[/FMP-Record][/FMP-InlineAction]

</SELECT>

Thanks again,

Mark Durgee

Posted

RE: One last problem... The drop down list only shows the first 25 records. How can I increase to show all customer names?

try -max = 100 or 1000.

Default value is 25 for [FMP-Record]

This topic is 7794 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.