Jump to content

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

Recommended Posts

Posted

Hi

I want to be able to search more than one field in my database for criteria entered into one search field. I have been trying to set hidden text fields on my search page, to the value of the search field, on submit, with Java scripts - but I can't get it to work - haven't had much exposure to Java Scripts.

Having a calculation field to search is not suitable either as one of the fields I need to search is a related field.

Does anyone know how i can acheive this??

Cheers

Hal.

Posted

A non-elegant-yet-working method would be that of creating a field calculated joining the fields you want to search on, and run the search on that

So you've fields

FirstName

LastName

you'd create an ALL field =

FirstName & " " &

LastName

and put the field ALL in the search form

Posted

Hi Hal smile.gif

Uh, you can search for information in related dBs also.

Write a calc, text (unstored), something like:

LName & " " & FName & " " & HR::LName

If the above calc then holds "Smith Jane Anderson" and you search for "anderson", it will find it. If the fields you need to search are of a different data type, you'll need to convert them to text. Let us know each field you wish to search on, and what the field type is for each field, and we'll help you write it! Set field format to allow entry into field. Search on it! Unless we're misunderstanding what you need, it works.

LaRetta

Posted

Hi, halbj! Can you get away with a combination of a calc field and an inline action? Maybe store the search criteria as a global or use JavaScript (or other) to simultaneously do 2 searches? You get 2 result lists but at least they're there. --ST

--------------------------

PUBLIC FYI: What we're talking about w/calc is combining all fields to be searched into 1 giant field that is searched instead, e.g.

everythingfield-calc=field1 + field2 + field3... (or for string concatenation...)

everythingfield-calc=field1 & " " & field2 & " " & field3, etc.

Posted

Your CDML would look like this to search on a related field:

<input type="text" name="myrelation::myfield">

As long as this field is on the FM Layout being used you should not have any problems.

All the best.

Garry

Posted

Thanks for your posts

I realise I can search on related fields and I realise I can have calculation field of the fields I want to search, but my relationship is 1 to many so I can't calculate that without a script and I would prefer not to use a script. eg

my search fields are 'Title' and 'Keywords::Keyword'. The relationship 'Keywords' is 1 - M. I want my users to be able to enter their search criteria into one field and have it search both. Does this make sense??

Hal.

Posted

Using:

<input type="text" name="Keywords::Keyword">

will search a one-to-many relationship.

To have one input and two search fields you would do this:

<script>

function submyform()

   {

   document.myform.title.value = document.myform.elements["Keywords::Keyword"].value ;

   document.myform.submit();

   }

</script>

</head>

<body>

<form name="myform" action="FMPro" method="post" onsubmit="submyform(); return false;">

.

<input type="hidden" name="title">

Enter Keyword:<input type="text" name="Keywords::Keyword">

<input type="hidden" name="-find">

<input type="submit" name="-find" value="Find Entries">

</form>

Hope this is of use.

All the best.

Garry

Posted

Thanks Garry - that is the solution I had in mind, but I didn't know how to do the script. It still is not working for me though. Can you see what is wrong with my code?

Thanks heaps

Hal.

____________________

<script>

function submyform()

{

document.Search.Keywords::keyword.value = document.Search.elements["TitleSet"].value ;

document.Search.submit();

}

</script>

</head>

<form name="Search" action="FMPro" method="post" onsubmit="submyform(); return false;" target="_Parent">

<input type="hidden" name="TitleSet"/>

<input type="hidden" name="-lop2" value="OR" />

<input type="hidden" name="-op" value="cn" />

<input name="Keywords::keyword" type="text" id="Keywords::keyword" size="50"/>

<input type="hidden" name="-find">

<input type="submit" name="-Find" value="Search" />

<input type="hidden" name="-DB" value="Precedents.fp5" />

<input type="hidden" name="-Lay" value="WEB" />

<input type="hidden" name="-format" value="search_results.htm"/>

<input type="hidden" name="-error" value="search_error.htm"/>

<input type="hidden" name="-SortField" value="portal" />

<input type="hidden" name="-SortOrder" value="Ascending" />

<input type="hidden" name="-max" value="10" />

<input type="hidden" name="-lop" value="AND" />

<input type="hidden" name="Status" value="Active" />

</form>

Posted

Hal,

Try this:

<script>

function submyform()

   {

   document.Search.elements["Keywords::keyword"].value = document.Search.TitleSet.value ;

   document.Search.submit();

   }

</script>
The (elements["Keywords::keyword"]) is being used because Javascript does not like the "::" used for a Relationship.



The <form> needs a bit of work also:
<form name="Search" action="FMPro" method="post" onsubmit="submyform(); return false;" target="_Parent">



                <input type="hidden" name="TitleSet"/>

                <input type="hidden" name="-lop" value="OR" />

                <input type="hidden" name="-op" value="cn" />

                <input name="Keywords::keyword" type="text" size="50"/>



                                   <input type="hidden" name="-find">

           <input type="submit" name="-Find" value="Search" />



          <input type="hidden" name="-DB" value="Precedents.fp5" />

          <input type="hidden" name="-Lay" value="WEB" />

          <input type="hidden" name="-format" value="search_results.htm"/>

          <input type="hidden" name="-error" value="search_error.htm"/>

          <input type="hidden" name="-SortField" value="portal" />

          <input type="hidden" name="-SortOrder" value="Ascending" />

          <input type="hidden" name="-max" value="10" />

    </form>

You can have only one "-lop". You could use an [FMP-If] tag in the Format file to exclude non-active records.

Good Luck.

Garry

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