3 Replies - 1914 Views - Last Post: 28 November 2011 - 05:00 AM Rate Topic: -----

#1 mossman65  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 19-September 11

Search Again Function

Posted 10 October 2011 - 06:11 AM

Good Morning!

I have a drill down search that we use for our products: http://www.griffinrad.com

When the results page is loaded, i would like the option for them to search again. Currently when i try to use the same search w/ drop downs on the results page it pre loads the variables from the first search.

How can i on the search page clear all the variables and start with a clean year select, or is there a better way for me to approach this?

Best Regards,
Aaron

Is This A Good Question/Topic? 0
  • +

Replies To: Search Again Function

#2 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1947
  • View blog
  • Posts: 3,488
  • Joined: 13-January 08

Re: Search Again Function

Posted 10 October 2011 - 09:00 AM

That would depend on how you've got the search page built. What you have right now is a form that is submitting to itself and with each additional selected item, the form is resubmitted. Basically, what you're doing is accruing form variables and then assuming that a new select field is needed regardless of the selection. Unfortunately, if you simply keep selecting a new year, no matter what it is you've selected, you'll get a new form field. It eventually broke on me.

There are a couple of different ways to fix this. One is to only have one select field active at a time. Once you select year, the form submits and rather than having a year select field and a make select field, show the previously selected year as a text string and only have the make field be active. Store the year in a hidden form field rather than as the selected item in a select field. For each form submission, check that you have populated form fields for each of the previous select fields. It'd look like a breadcrumb trace: "2006, Jeep, Wrangler, 2.5-4.0L" etc and at the end, you have a "Clear Search" button that returns the original forms with no previously selected form values.

You could also use JQuery to retain the select drop downs but handle any changes made midway through. Like if you select the year, make and model...and then go back and change the year...you'd want to wipe out any previous selections to the "right" of that I should think.

I'd fix what you have on your home page first and then simply copy it over to any subpage you may want to include it on.
Was This Post Helpful? 0
  • +
  • -

#3 mossman65  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 19-September 11

Re: Search Again Function

Posted 10 October 2011 - 11:43 AM

View PostCraig328, on 10 October 2011 - 09:00 AM, said:

There are a couple of different ways to fix this. One is to only have one select field active at a time. Once you select year, the form submits and rather than having a year select field and a make select field, show the previously selected year as a text string and only have the make field be active. Store the year in a hidden form field rather than as the selected item in a select field. For each form submission, check that you have populated form fields for each of the previous select fields. It'd look like a breadcrumb trace: "2006, Jeep, Wrangler, 2.5-4.0L" etc and at the end, you have a "Clear Search" button that returns the original forms with no previously selected form values.


Thank you Craig for your reply! I see what your saying with subbmiting the form one step at a time. I'm using:

<cfquery name="get_Main_Group" datasource="" username="" password="">
    SELECT DISTINCT Year
    FROM GDR
    ORDER BY Year DESC
</cfquery>
<select style="width:150px; border-color:##666666; font-size:22px"  name="select_Main_Group" required="yes" onchange="this.form.submit()">



Would it be best to do a if statement around the javascript like so:

<select style="width:150px; border-color:##666666; font-size:22px"  name="select_Main_Group" required="yes" <cfif get_product_id.recordcount gt 0> onchange="this.form.submit()"</cfif>




Thank you!
Was This Post Helpful? 0
  • +
  • -

#4 advinsteven  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 08-August 11

Re: Search Again Function

Posted 28 November 2011 - 05:00 AM

Many times, I try to use the Search function to search the Star Wars community boards, and the screen comes back blank.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1