close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Using addComparisonFromList

Thread began 5/11/2012 8:34 am by jay.malik396220 | Last modified 5/11/2012 2:58 pm by Jason Byrnes | 1467 views | 5 replies |

jay.malik396220

Using addComparisonFromList

Have a select list and need to have the default option "All" return all records, then have remaining options filter records appropriately.

what is the correct way to use the search.

I have the following code where status is the column and S-status is the select field on the form.

$WADbSearch1->addComparisonFromList("status","S_status","AND","Includes",0);

Can't get this to work - no records show.

The "All" list item has a null value.

Sign in to reply to this post

Jason ByrnesWebAssist

the value for the all list item needs to be left blank:

<option value="">Show All</option>

Sign in to reply to this post

jay.malik396220

Great, now the inevitable follow up

That worked on our page which has search above the results.

Only challenge now is that the serach field does not retain the value selected for the search. Suggestions?

I tried using code like this:


$status_array = array("All", "New Call", "IR in Progress", "Requires Follow-up", "Quote", "Complete", "Closed");
for($i=0;$i<count($status_array);$i++)
{
if($status == $status_array[$i]){ $selected = "selected"; }
$option_Status .= "<option value=\"$status_array[$i]\" $selected>$status_array[$i]</option>\n";
$selected = "";
}

<option selected="selected"><?php print $option_status; ?></option>

But the page blew up on the search.

Sign in to reply to this post

Jason ByrnesWebAssist

not really sure form the code snippet, but shouldn't:
<option selected="selected"><?php print $option_status; ?></option>


be just:
<?php print $option_status; ?>


at the end of the day you are suing custom code for creating the select list, so it is going to be pretty difficult for me to troubleshoot this for you.

Sign in to reply to this post

jay.malik396220

You are correct and I had since fixed this

So the question really is where can I best trap the last list item selection before the search takes place.

The problem is that $status is null before reaching the loop:

$status = trim($_POST['S_status']);
.
.
.
$status_array = array("", "New Call", "IR in Progress", "Requires Follow-up", "Quote", "Complete", "Closed");
for($i=0;$i<count($status_array);$i++)
{
if($status == $status_array[$i]){ $selected = "selected"; }
$option_status .= "<option value=\"$status_array[$i]\" $selected>$status_array[$i]</option>\n";
$selected = "";
}

so the "" select item is always being marked as selected. $status should have retained the last entered value, then set selected to that list item.

$option_status keeps being set to the following in this loop:

<option value="" selected></option>
<option value="New Call" >New Call</option>
<option value="IR in Progress" >IR in Progress</option>
<option value="Requires Follow-up" >Requires Follow-up</option>
<option value="Quote" >Quote</option>
<option value="Complete" >Complete</option>
<option value="Closed" >Closed</option>

Sign in to reply to this post

Jason ByrnesWebAssist

it's hard for me to tell only seeing the small snippet. Are you sure the method of the form is to post? if this code
$status = trim($_POST['S_status']);

is always returning "", then perhaps the form isn't sending the info using the post array, but using the GET array instead.

Sign in to reply to this post

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...