Search options

4 posts by 2 authors in: Forums > CMS Builder
Last Post: August 2, 2012   (RSS)

By apolgree - August 1, 2012

If you check out http://wmcyo.com/teams.php you will see that under the "Team Index & Search" header, I have two independent dropdown menus that simply direct people to search URL's. One is for GRADE LEVEL and one for TOWN.

Both dropdown menus function as expected based on how the page is coded, but what I would like is for the two dropdown menus to be related. Meaning, that if I select Grade 3-4 in the first dropdown and then Holyoke in the second dropdown, I should get the Grade 3-4 teams in Holyoke. Right now the dropdown menus are independent of each other. I know I could put these search options into one form and have a submit button, but part of this is that I want to generate URL's that can be bookmarked and the other part is that I don't want there to be a submit button.

The ideal thing would be that there would be multiple dropdowns, one for each category, that by default would be set to "ALL TEAMS"...then every time someone selected a value from the dropdown it would go to the appropriate URL based on the collective dropdown values.

Also, it would be great if the selected value held in the dropdown menu, instead of resetting to the default. That way people could see what they have selected. For instance in my example above, the person would see "3-4" in the left dropdown menu and "Holyoke" in the right dropdown menu and be at this URL:
http://wmcyo.com/teams.php?grade_level,content_keyword=3-4&title,content_keyword=Holyoke

Any advice would be much appreciated.

Re: [apolgree] Search options

By Jason - August 1, 2012

Hi,

You're right that the best option would be to to have the form submit. If you set your form method to "get", then the options you select will appear in the URL so the page would be bookmarkable.

If you don't want a submit button, you can have a submit function that is called on the onchange event of your drop downs. The event will submit your form so you don't need a separate button. Take a look at this article:
http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml

Finally, you can use the selectedIf() function to maintain your drop downs state.

For example:

<select onchange="submitForm();" size="1" name="grade_level,content_keyword">
<option value="">BY GRADE LEVEL</option>
<option value="3-4" <?php selectedIf("3-4", @$_REQUEST['grade_level,content_keyword']);?>>3-4</option>
<option value="5-6" <?php selectedIf("5-6", @$_REQUEST['grade_level,content_keyword']);?>>5-6</option>
<option value="7-8" <?php selectedIf("7-8", @$_REQUEST['grade_level,content_keyword']);?>>7-8</option>

</select>


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/

Re: [apolgree] Search options

By Jason - August 2, 2012

Hi,

%2C denotes a comma in the URL string. It's just the way the url is encoded so that special characters are interpreted correctly. There isn't really a good way to remove them, but they won't affect the way your page works

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/