close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Creating a Search Form using Check boxes

Thread began 12/09/2009 11:30 am by karen.marley367377 | Last modified 12/22/2009 12:58 pm by Jason Byrnes | 1734 views | 10 replies |

karen.marley367377

Creating a Search Form using Check boxes

Hi
I have a table with a list of types to select. On the Search form, I want the user to be able to tick a check box to select a type, rather than a drop down list. Can you give me any tips on how to do this?

Sign in to reply to this post

Jason ByrnesWebAssist

you will probably want to use radio button instead of checkboxes.

Probably the simplest way to make this work will be to get it working with a select list fist. Once the search is working with a select list, make not of the select list name, then delete it and replace it with a radio group.

make sure the radio group has the same name and set the value form each radio button to be the value in the database.

Sign in to reply to this post

karen.marley367377

using radio bx group

Thanks Jason,

That works fine. I now want the user to be able to make more than one selection. i.e. radio button 1, and radio button 2, and radio button 3

Can you help please?

Sign in to reply to this post

Jason ByrnesWebAssist

Then change the radio buttons to checkboxes;


type="radio"


to

type="checkbox"

Sign in to reply to this post

karen.marley367377

Form Using Multiple Check Boxes, Want initial page load to show All

Hi,

I have created a search form on the results page, using a couple of drop down lists and multiple check boxes.

Whe the page loads, or one of the drop down boxes is selected the page shows no results.

In order for results to show, one or more of the check boxes needs to be selected.

How can I have the initial page load to show all records, or have one of the drop lists show values without having to tick one of the check boxes?

The code from the page is as follows:

<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: WADAproperties;
//Searchpage: properties_Search.php;
//Form: WADASearchForm;
$WADbSearch1_DefaultWhere = "";
if (!session_id()) session_start();
if ((((isset($_GET["submit"]))?$_GET["submit"]:"") != "")) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations

//comparison list additions
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Assembly"]))?$_GET["Assembly"]:"") ."","AND","=",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["HealthDay"]))?$_GET["HealthDay"]:"") ."","OR","Includes",0);
$WADbSearch1->addComparisonFromList("SaleORLease","status","AND","=",0);
$WADbSearch1->addComparisonFromEdit("RegionName","region","AND","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Industrial"]))?$_GET["Industrial"]:"") ."","OR","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Investment"]))?$_GET["Investment"]:"") ."","OR","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Land"]))?$_GET["Land"]:"") ."","OR","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Licenced"]))?$_GET["Licenced"]:"") ."","OR","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Mixed"]))?$_GET["Mixed"]:"") ."","OR","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Motor"]))?$_GET["Motor"]:"") ."","OR","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Office"]))?$_GET["Office"]:"") ."","OR","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Residential"]))?$_GET["Residential"]:"") ."","AND","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Retail"]))?$_GET["Retail"]:"") ."","OR","Includes",0);
$WADbSearch1->addComparison("PropertyType","".((isset($_GET["Storage"]))?$_GET["Storage"]:"") ."","OR","Includes",0);
$WADbSearch1->addComparison("RegionName","".((isset($_GET["region"]))?$_GET["region"]:"") ."","AND","=",0);
$WADbSearch1->addComparison("SaleORLease","".((isset($_GET["status"]))?$_GET["status"]:"") ."","AND","=",0);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_properties_Results"]=$WADbSearch1->whereClause;
}
}
else {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//get the filter definition from a session variable
if (1 == 1) {
if (isset($_SESSION["WADbSearch1_properties_Results"]) && $_SESSION["WADbSearch1_properties_Results"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_properties_Results"];
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereClause = '';
?>

Originally Said By: Jason Byrnes
  Then change the radio buttons to checkboxes;


type="radio"


to

type="checkbox"  
Sign in to reply to this post

karen.marley367377

Check Boxes - When single ones selected works fine but not when multiple selected

Have resolved my last reply issue, but now have another one! X

Have created multiple check boxes to look at one field in the main table recordset.

When each selected singularly the check boxes show the correct results. The problem is when more than one check box is ticked. I am using the DATA Assist Search Server Behaviour and the code is posted below:

<?php
//WA Database Search (Copyright 2005, WebAssist.com)
//Recordset: WADAproperties;
//Searchpage: properties_Search.php;
//Form: WADASearchForm;
$WADbSearch1_DefaultWhere = "";
if (!session_id()) session_start();
if ((((isset($_GET["submit"]))?$_GET["submit"]:"") != "")) {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//keyword array declarations
$KeyArr1 = array("PropertyType");

//comparison list additions
$WADbSearch1->addComparisonFromEdit("PropertyType","Assembly","AND","Includes",0);
$WADbSearch1->addComparisonFromEdit("PropertyType","HealthDay","AND","Includes",0);
$WADbSearch1->addComparisonFromList("SaleORLease","status","AND","=",0);
$WADbSearch1->addComparisonFromEdit("RegionName","region","AND","Includes",0);
$WADbSearch1->keywordComparison($KeyArr1,"".((isset($_GET["Industrial"]))?$_GET["Industrial"]:"") ."","AND","Includes",",%20","%20","%22","%22",0);
$WADbSearch1->addComparisonFromList("PropertyType","Investment","AND","Includes",0);
$WADbSearch1->addComparisonFromList("PropertyType","Land","AND","=",0);
$WADbSearch1->addComparisonFromList("PropertyType","Licenced","OR","Includes",0);
$WADbSearch1->addComparisonFromList("PropertyType","Mixed","AND","Includes",0);
$WADbSearch1->addComparisonFromList("PropertyType","Motor","AND","Includes",0);
$WADbSearch1->addComparisonFromList("PropertyType","Office","AND","Includes",0);
$WADbSearch1->addComparisonFromList("PropertyType","Residential","AND","Includes",0);
$WADbSearch1->addComparisonFromList("PropertyType","Retail","AND","Includes",0);
$WADbSearch1->addComparisonFromList("PropertyType","Storage","AND","Includes",0);
$WADbSearch1->addComparison("RegionName","".((isset($_GET["region"]))?$_GET["region"]:"") ."","AND","=",0);
$WADbSearch1->addComparison("SaleORLease","".((isset($_GET["status"]))?$_GET["status"]:"") ."","AND","=",0);

//save the query in a session variable
if (1 == 1) {
$_SESSION["WADbSearch1_properties_Results"]=$WADbSearch1->whereClause;
}
}
else {
$WADbSearch1 = new FilterDef;
$WADbSearch1->initializeQueryBuilder("MYSQL","1");
//get the filter definition from a session variable
if (1 == 1) {
if (isset($_SESSION["WADbSearch1_properties_Results"]) && $_SESSION["WADbSearch1_properties_Results"] != "") {
$WADbSearch1->whereClause = $_SESSION["WADbSearch1_properties_Results"];
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
else {
$WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;
}
}
$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);
$WADbSearch1whereClause = '';
?>

Can you see where the problem lies ?

Many thanks

Sign in to reply to this post

Jason ByrnesWebAssist

Please send the full php page in a zip archive so I can see the form code as well as the DataAssist search code.

Sign in to reply to this post

karen.marley367377

Check Boxes for Multiple Select

Hi Jason,

I have attached a zip file for your perusal.

Many thanks and regards,

Attached Files
checkboxes.zip
Sign in to reply to this post

Jason ByrnesWebAssist

Sorry, I need a little clarification, you say it works when one is selected, but if more than one is selected it does not, can you explain what you mean by this? What is the result you are getting when more than one is selected versus the results you are expecting?

Sign in to reply to this post

karen.marley367377

Check Box Selection

Apologies Jason, the check boxes now select expected records, expect....

The recordset is filter by a session variable - i.e. members id. When the page is loaded or the drop down lists in the search form are selected, it shows just the records entered by the particular member. when the check boxes are selected however, it shows all the members records ! X Help! X

$MMPARAMSLNID_WADATABLENAME = "1";
if (isset($_SESSION['SESSIONNAME'])) {
$MMPARAMSLNID_WADATABLENAME = (get_magic_quotes_gpc()) ? $_SESSION['SESSIONNAME] : addslashes($_SESSION['SESSIONNAME]);

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...