Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Using FM value list in the web form search

Featured Replies

I have a projects DB where I am applying "tags" via a multiple checkbox field. I would like to make this field available on the webpage for searches to find the relevant projects.

I was successful using a text box field but it would be much more user friendly to have checkboxes of available tags. As time goes on, the tags list may grow. So my question is how would I code the value list options as checkboxes into a search field on the web. My code works for the text field and a single checkbox but not multiple checkboxes.

I tried to create a search array using some manual entries and $find = $_POST['search','search1'] but this didn't seem to work. In any event I don't wish to code the options and I would like the list to be dynamic to reflect the Value list which only give values found in that field. In the code below $options are the values that I would like the checkboxes to be.

 

You can see the results at arina.biz/phptest.php

 

I have attached the whole code for reference.

 

 

/*================================================================
*
*       Get list of Tagss before creating the form
*
*=================================================================*/
$cmd =& $connection->newFindCommand('WebSearch'); $cmd->addFindCriterion('seachvaluelist', '*');
$result1 = $cmd->execute();



$records = $result1->getRecords();
$record = $records[0];

//the GET VALUE COMMAND
$options = $record->getField("seachvaluelist");

Echo 'Enter key words and click <b>SUBMIT</b> (or <b>RETURN</b> key)<br><br><br>';
echo 'Choose from… '.$options.'<br><br>';
Echo 'Separate multiple Key words with a space.<br>';

?>

<form action='phptest.php' method="post" enctype="multipart/form-data">
    <input type="text" name="search"><br>
    <input type="checkbox" name="search" value="Anatomy"> <label for="search">Anatomy</label><br>
    <input type="checkbox" name="search1" value="STEM"> <label for="search1">STEM</label><br>
    <input type="checkbox" name="search2" value="Laboratory"> <label for="search2">Laboratory</label><br>
    <input type="checkbox" name="search3" value="Informallearning"> <label for="search3">Informal learning</label><br>
    <input type="submit">

</form>

<?php

/* ===================================================================
 search and print
 ===================================================================*/
$find = $_POST['search'];

 

 

 

Edited by Aussie John
updated the PHP

  • Author

I have found this snippet which gives me what I want but I dont seem to be able to get the selections to find. I suspect checking the box and hitting submit doesn't parse the actual text value. Any suggestions for this?

$layout =& $connection->getLayout('WebSearch');
$values = $layout->getValueList('SearchTags');
foreach($values as $value){ 
      echo '<input type= "checkbox" name= "SearchTags" value= "'. $value .'">' . $value . ' ';
}

 

Edited by Aussie John
Discovered the error: $FM should have been $Connection

Hi John

The getValueList method is deprecated and replaced with getValueListTwoFields.

See the API documentation on your server for details.

  • Author

Thank IdealData. Point noted but I am still having trouble getting the result of the checkbox selections.

Using the text box for the search returns a result but using the checkboxes doesn't. see arina.biz/phptest.php

Any thoughts?

 

$layout =& $connection->getLayout('WebSearch');
$values = $layout->getValueList('SearchTags');
foreach($values as $value){ 
      echo '<input type= "checkbox" name= "Search" value= "'. $value .'">' . $value . ' ';

}
// echo "<br>search";
//===========================================================
?>
<form action='phptest.php' method="post" enctype="multipart/form-data">
 <input type="text" name="Search">
<input type="submit">
<br>
</form>

<?PHP

/* ===================================================================
Print
 ===================================================================*/
$find = $_POST['Search'];

echo "Last search was for… <b>$find</b>";

 

You need to make the names of the checkbox inputs part of an array, and then use the newCompoundFindCommand() in the php api.

I am assuming that since you are using check boxes instead of Radio buttons, you foresee the need to select multiples.

See if these help. You will have to put them on your servers and massage the paths a bit, of course.

checkbox.zip

  • Author

Thanks Doughemi 

You put a lot of effort in to your response and that was very helpful. 

Edited by Aussie John

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.