close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Retaining Search criteria on combined Search/Results page

Thread began 2/11/2011 1:45 pm by paul386190 | Last modified 2/14/2011 9:30 am by Jason Byrnes | 1775 views | 9 replies |

paul386190

Retaining Search criteria on combined Search/Results page

Hi there
I've been working with the Data Assist Search Wizard and have been able to set up a single page which combines both the search and the results. The problem I'm struggling with is displaying the original search criteria on the search form when the page reloads to display the results.

Basically, my form is made up of a number of questions which each have their own group of checkboxes so that the visitor can select more than one option for each question. When the submit button is hit, the correct results are displayed on the page but the checkboxes that were checked for the search are now empty again. What I would like is for the visitor to be able to either deselect some of their original choices in the search form or check a few more and then perform another search.

I would be very grateful for any guidance on how I may resolve this?
Many thanks in advance.
Paul

Sign in to reply to this post

Jason ByrnesWebAssist

select each checkbox in design view, then in the Property inspector, click the Dynamic button.

next to chec kif, click the lightning bolt icon and select the checkbox form the form group.

next to equal to, enter the value for that checkbox.

Sign in to reply to this post

paul386190

HI Jason, many thanks for the swift response.
Unfortunately though that doesn't appear to have made any difference.

Below is the code I have in the form which I've amended as you suggested...

<label>
<input <?php if (!(strcmp(((isset($_POST["search_usage[]"]))?$_POST["search_usage[]"]:""),1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="search_usage[]" id="search_usage_0" value="1" />
Light</label>
<label>
<input <?php if (!(strcmp(((isset($_POST["search_usage[]"]))?$_POST["search_usage[]"]:""),2))) {echo "checked=\"checked\"";} ?> type="checkbox" name="search_usage[]" id="search_usage_1" value="2" />
Medium</label>
<label>
<input <?php if (!(strcmp(((isset($_POST["search_usage[]"]))?$_POST["search_usage[]"]:""),3))) {echo "checked=\"checked\"";} ?> type="checkbox" name="search_usage[]" id="search_usage_2" value="3" />


and below is what is being displayed in the comparison list additions of the search script...

$WADbSearch1->addComparisonFromList("search_usage","search_usage","AND","=",1);


The "AND" is there as I have more groups of checkboxes within the form but it kind of made sense to just highlight one for the moment. Basically I have a list of products which have all been assigned a level of 'usage' - 1, 2 or 3 - which is recorded in the database in a column named 'search_usage' and I'm giving the visitor the chance to see any combination of machines, ie Just those with level 1 or those with level 1 & 2.

The form is functioning correctly in that it is displaying the right results but we're just not seeing the original checks in the boxes of the search panel.

Again, any guidance would be greatly appreciated.
Kind regards
Paul

Sign in to reply to this post

Jason ByrnesWebAssist

strip the "[]" from the php code:

change:

php:
<input <?php if (!(strcmp(((isset($_POST["search_usage[]"]))?$_POST["search_usage[]"]:""),1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="search_usage[]" id="search_usage_0" value="1" />

Light</label>



to:

php:
<input <?php if (!(strcmp(((isset($_POST["search_usage"]))?$_POST["search_usage"]:""),1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="search_usage[]" id="search_usage_0" value="1" />

Light</label>
Sign in to reply to this post

paul386190

Hi Jason

Many thanks for your continued support. Unfortunately I tried that along with a few other combinations over the weekend and it still doesn't seem to resolve the issue. It does indeed the correct results, but still isn't retaining the checks in the search box. I've attached the entire code for the page and wonder if there is anything glaring that looks to be the issue? I would be really grateful for any input - thank you in advance.
Kind regards
Paul

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

Jason ByrnesWebAssist

Ahhh, I see, the syntax for multiple select lists is slightly different:


php:
<input <?php if((isset($_POST["search_usage"])) && (is_array($_POST["search_usage"])) && (in_array("1",$_POST["search_usage"])))  {echo "checked=\"checked\"";} ?> type="checkbox" name="search_usage[]" id="search_usage_0" value="1" />
Sign in to reply to this post

paul386190

Hi Jason

That's perfect, thank you so much for your swift and continued assistance.

Just one final question if that's okay - is there anyway that when this page first loads that all of the checkboxes are checked so that all products are listed initially? The visitor would then simply deselect the options they don't want - from a marketing point of view it will help as all of their products will be visible to see at least once.

I did try simply adding..... checked="checked" ...... into each option, but obviously when the pages reloads they all appear checked again. I have worked a way around it by having a duplicate of the page with the above code added to all the options, then when SUBMIT is first hit it goes to the combined Search/Results page you've been helping me with which is then used from then on. The only downside with this is that since I'm running two very similar pages, any changes would have to be applied to both as opposed to just one.

It's not a deal breaker but would be the icing on the cake if I could just retain the one page.

Many thanks again.
Kind regards
Paul

Sign in to reply to this post

Jason ByrnesWebAssist

add an OR condition to the if statement:

php:
<input <?php if(((isset($_POST["search_usage"])) && (is_array($_POST["search_usage"])) && (in_array("1",$_POST["search_usage"]))) || (!isset($_POST["search_usage"])))  {echo "checked=\"checked\"";} ?> type="checkbox" name="search_usage[]" id="search_usage_0" value="1" />
Sign in to reply to this post

paul386190

You're a star - thank you. You can probably tell I don't have much skill in hand coding php.
Thank you for bearing with me.

Kind regards
Paul

Sign in to reply to this post

Jason ByrnesWebAssist

No worries.

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