search with two drop downs

8 posts by 3 authors in: Forums > CMS Builder
Last Post: October 25, 2011   (RSS)

By petejdg - October 23, 2011

I am trying to create a form search with two drop down selects where the value chosen in the first will update the value in the second. The first drop down is a Product Line - the second drop down is a U.S./Canada list. So user would choose which product they are interested in, then choose the State/Canadian Provice where they live. In the admin side I just have a Dealer record that has each product with the State/Canadian multiselect as each Dealer can have either of 5 product lines and serve different states. This might not be the best way to do it, but it is what I came up with. I just need to figure out how to take the Product Line selected and pass that to the State/Province value to search by.

<form method="POST" action="/wilsontrailer.php">
<input type="submit" name="submit" value="Search">
<select name="" id="">
<option value="gooseneck">Gooseneck</option>
<option value="grain">Grain</option>
<option value="livestock">LIvestock</option>
<option value="flatbed">Flatbed</option>
<option value="belt">Belt</option>
</select>
<select name="gooseneck_keyword" id="state">
<option>CHOOSE OPTION</option>
<optgroup label="United States">
<option id="AL" value="AL">Alabama (AL)</option>
<option id="AK" value="AK">Alaska (AK)</option>
<option id="AZ" value="AZ">Arizona (AZ)</option>
<option id="AR" value="AR">Arkansas (AR)</option>
<option id="CA" value="CA">California (CA)</option>....
Wouldn't it be fairly easy to just do a variable on the first select that would be passed into the value of the second?

Re: [petejdg] search with two drop downs

By Dave - October 24, 2011

Hi petejdg,

We don't have any easy code for this, but I think what you are looking for is called "chained selects".

Here's a google link: http://www.google.com/search?q=chained+selects

There's a number of scripts that let you update one select pulldown from another.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] search with two drop downs

By petejdg - October 24, 2011

Dave, I was able to get the select drop downs working correctly with your link. Thanks. Now my dilemma is how to actually make the search work correctly, but I don't even know if it can. I thought this would be fairly simple but seems definitely not. Since it is pulling my list - I can't tell any of the form variables. I don't know if anyone can help or how bad of a custom job this would be?

Re: [petejdg] search with two drop downs

By Jason - October 24, 2011

Hi,

When your form is submitted, are you able to get the values that were selected from your drop down boxes?
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] search with two drop downs

By petejdg - October 24, 2011 - edited: October 24, 2011

Good question. Since they aren't populating the the html I don't know. But I am pretty sure it won't work as the value of the main select is being set - I assume that has to be a variable to pull in my search params like "gooseneck_keyword". I am attaching the files but in the wilsontrailersearch.php the coding is:<select name="trailertypes" style="width:160px;"></select> and I assume the trailertypes has to be one of my trailer searches with _keyword???

Re: [Jason] search with two drop downs

By petejdg - October 25, 2011

Thanks... but I don't really know php so I think this is now way over my head.

Re: [petejdg] search with two drop downs

By Jason - October 25, 2011

Hi,

No problem. If you need some help getting this done, please send an email to consulting@interactivetools.com and we can explore some options for getting this set up for you.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/