Jump to content

drop down list to select field


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

Recommended Posts

Hi All,

Thought this would be easy, but I can't work out the elegant way to acheive it.

I have a drop down list which contains all my field names. Using this, my users can select the field they want results to sort by when submitting a form. Easy.

My problem is that the field names don't translate to human readable format. eg. I have a field called "serialNumber", but I want the list to show "Serial Number". Or worse, field is "sites::siteCode", list should display "Site Code".

I could use if statements, but I'm sure there must be a more efficient way.

Appreciate any help!

Cheers...Sean.

Link to comment
Share on other sites

Hi Garry,

Automating sounds like a good idea, but I'm still trying to figure all this stuff out so first step I was just going to type them into the page.

I imagine it will be even trickier when I try to automate...

Thanks,

Sean.

Link to comment
Share on other sites

You can just add them like this:

<select name="fields">

<option value="serialNumber">Serial Number</option>

<option value="sites::siteCode">Site Code</option>

.....

</select>

You could then read them with:

$selection_field = $_POST['fields'];

Hope this helps. All the best.

Garry

Link to comment
Share on other sites

Hi Garry,

So, simple. I should have been able to work that out.

Thank you!!

So, in order to save me much stumbling about, can you point me in the right direction for automating this?

Thanks again,

Sean.

Link to comment
Share on other sites

I think you should be able to get a list of field names with:

[FMP-LayoutFields]

[FMP-FieldName]

[/FMP-LayoutFields]

An example from the CDML Reference database:

<select name="fields">

<option value="">-None- [FMP-LayoutFields]

<option>[FMP-FieldName: Raw] [/FMP-LayoutFields]

</select>

All the best.

Garry

Link to comment
Share on other sites

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