close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Reset Dropdown List in Search Form

Thread began 1/29/2010 4:42 pm by jurinski334466 | Last modified 12/02/2014 6:51 am by lrgraphics315137 | 4267 views | 7 replies |

jurinski334466

Reset Dropdown List in Search Form

I have a search form on the results page where I am having trouble clearing the value in the dropdown list. I would like to keep the selected value during a search but also be able to clear and reset the form so all results show, and the list returns to the default position. Is this possible?

I tried clearing the session variable with a link and clear=true on the results page, and on the results page and the search page, and also trying to use a separate page to try to reset the list. I think the problem maybe the recordset select statement which includes an AS column.

mysql_select_db($database_newbbcpeConn, $newbbcpeConn);
$query_WADADynListendtimelist = "SELECT endtimelist.EndTimeListID, endtimelist.EndTime, TIME_FORMAT( endtimelist.EndTime, '%l:%i %p') AS EndingTime FROM endtimelist ORDER BY endtimelist.EndTime ASC";
setQueryBuilderSource($query_WADADynListendtimelist,$WADbSearch1,false);
$query_limit_WADADynListendtimelist = sprintf("%s LIMIT %d, %d", $query_WADADynListendtimelist, $startRow_WADADynListendtimelist, $maxRows_WADADynListendtimelist);
$WADADynListendtimelist = mysql_query($query_limit_WADADynListendtimelist, $newbbcpeConn) or die(mysql_error());
$row_WADADynListendtimelist = mysql_fetch_assoc($WADADynListendtimelist);

How do I reset the search so that when the search button is pressed it loads all the
results and resets the dynamic list to the default selected value?

Thank you for any help.

Sign in to reply to this post

Eric Mittman

The way that DataAssist works is through the trigger you specify. When this trigger is encountered the search values will be stored in a session variable. The search will show these results anytime that you browse to this results page without triggering a new search.

To clear a previous set of results you just need to trigger the search without any values specified.

What do you have the trigger setup as? Also, how would you like the user to reset the results to get back all of them? Do you want them to click on a show all button or something like that?

Sign in to reply to this post

jurinski334466

Thanks for your reply.

The search form works great for searching the data; however, I also need to have either a link or a button which clears the search and shows all the results and resets the dropdown list to its default value.

I'm sorry, but I'm not sure what the trigger for the search/results page is called. Where in the code do I find that value?

Right now, I am trying to clear the search using this link added to the form:

<a href="endtime-results.php?clear=true"><em>ResetSearch</em></a>

And this code at the top of the page:

<?php
if(!session_id()) session_start();
if(isset($_SESSION["WADbSearch1_endtimeresults"]) && isset($_GET['clear']) && $_GET['clear'] == "true") {
unset($_SESSION["WADbSearch1_endtimeresults"]);
}
?>

This link works to clear all the search results but does not clear the dropdown list. Instead, the dropdown list returns to the first recordset value of 11:00 am and not the default value of "Search Ending Times."

This is the code for the dropdown list:

<select name="S_EndTime" id="S_EndTime">
<option value="" <?php if (!(strcmp("", $row_WADAendtimelist["EndTime"]))) {echo "selected=\"selected\"";} ?>>Search Ending Times</option>
<?php
do {
?>
<option value="" <?php if (!(strcmp("", $row_WADAendtimelist["EndTime"]))) {echo "selected=\"selected\"";} ?>>Search Ending Times</option>
<?php
do {
?>
<option value="<?php echo $row_WADADynListendtimelist['EndTime']?>"<?php if (!(strcmp($row_WADADynListendtimelist['EndTimeListID'], $row_WADAendtimelist["EndTimeListID"]))) {echo "selected=\"selected\"";} ?>><?php echo $row_WADADynListendtimelist['EndingTime'] ?></option>
<?php
} while ($row_WADADynListendtimelist = mysql_fetch_assoc($WADADynListendtimelist));
$rows = mysql_num_rows($WADADynListendtimelist);
if($rows > 0) {
mysql_data_seek($WADADynListendtimelist, 0);
$row_WADADynListendtimelist = mysql_fetch_assoc($WADADynListendtimelist);
}
?>
</select>

I would appreciate help figuring out how to completely clear the search. Thank you.

Sign in to reply to this post

Eric Mittman

Since you are able to clear the results out you should be able to get the select list to show the first value as selected by adding in the selected attribute to the first option like this:

php:
<select name="S_EndTime" id="S_EndTime">

<option value="" selected="selected">Search Ending Times</option>



You might still have this problem though if there are any matches from the recordset that you are working with in the list. Please post back with the page in question in a zip archive and I will take a look to let you know how you can get this other recordset to not have any values initially.

Sign in to reply to this post

jurinski334466

Thanks Eric, for taking a look at the page. I appreciate your help as I'm in over my head...

I changed the select list as you suggested. Now the dropdown list and the results list clear, but search and list values are no longer retained in the dropdown list.

I also tried editing the search statements and changing the Dynamic list values to see whether this affected the result.

I am trying to get this form field working before incorporating it into another form or at least get the form working independently.

I sent you both the results, and the search page, in the attached zip file. Please let me know if you need anything more.

Thanks again for your help.

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

Eric Mittman

I'm having a hard time understanding what is not working correctly in the search and results pages. Do you have a link that I can use to see this? I think this would be best.

In general you should be able to set the contents of a select list from a recordset. If you want to show what selection was made you can use the dynamic property in the property inspector to set the selected value to a value from a recordset or a posted value. If you are setting it to be initially selected based on a recordset value and it is not being reset it is because the recordset is still returning the same value.

Sign in to reply to this post

lrgraphics315137

Hi Eric
You have to clear S_Endtime after the search and before the dynamic list. If you need to keep the info for some other code pass the info to a temp variable and use that variable for the other code see below
AFTER SEARCH CODE
<?php
if ($_GET['S_EndTime'] != "") {
$S_EndTimeX = $_GET['S_EndTime']; // pass to temp variable if need variable contents
$_GET['S_EndTime'] = ""; // clear variable
}
?>
BEFORE DYNAMIC LIST

Sign in to reply to this post

lrgraphics315137

RESET DYNAMIC <SELECT> LIST

No It's not the result he wants to reset it's the dynamic drop down list he wants to reset!!!!!!!!!

I have the same problem on one of my clients sites. On the products results page I have search parameters on the left col, and a menu selection at top when hovering products link. now if you select a menu main group item it sets the search param to S_prodGroupID=5 say then goes to results page shows the products with a group ID of 5 OKAY.
But then if you go to the left col to select another group selection the drop down list only shows from item 5 down.

How after getting the results for the first search do you reset the drop down list???????

Website: www.aworldoffires.co.uk

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