Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

filter data with drop down menus

Explorer ,
Aug 24, 2007 Aug 24, 2007
I have my admin page that is a list of records, nothing special. But I want to let the user filter the data on a few fields using drop down boxes with an "apply filter" button. Each filter has the option to see all (%). I can filter it by the 3 different fields without any problems but here are my 2 problems:

When the user makes their selections from the drop down boxes then clicks the button, it does the filter but then each drop down goes back to the top option. So I need to set the current selection to what they just picked. How do I do this?

I think if I get the first one answered this next one will be ok. If there's enough records in the filter to need paging, it just pages to the default selections from the drop downs.
TOPICS
Server side applications
312
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 24, 2007 Aug 24, 2007
Mark.P. wrote:
> When the user makes their selections from the drop down boxes then clicks
> the button, it does the filter but then each drop down goes back to the top
> option. So I need to set the current selection to what they just picked. How
> do I do this?

You don't say which server-side language you're using, but the same
principle applies to all of them. Add a conditional statement into each
<option> tag, compare the current value with the value submitted by the
form, and if they match, insert selected="selected" (or just selected,
if you're using HTML 4.01).

In PHP:

<option value="products" <?php if ($_POST['filter'] == 'products') {
echo 'selected="selected"'; ?>>Products</option>

and so on...

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 24, 2007 Aug 24, 2007
sorry, i did forget the language. It's asp. I'll see if I can work through this, I don't know PHP at all but I'll give it a shot.

Thanks
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 24, 2007 Aug 24, 2007
Okay, that took care of my first problem but not the second. I used Request.Form like

<select name="activeList" id="activeList">
<option value="0" <%If (Not isNull(Request.Form("activeList"))) Then If ("0" = CStr(Request.Form("activeList"))) Then Response.Write("selected=""selected""") : Response.Write("")%>>Active</option>
<option value="1" <%If (Not isNull(Request.Form("activeList"))) Then If ("1" = CStr(Request.Form("activeList"))) Then Response.Write("selected=""selected""") : Response.Write("")%>>Inactive</option>
<option value="%" <%If (Not isNull(Request.Form("activeList"))) Then If ("%" = CStr(Request.Form("activeList"))) Then Response.Write("selected=""selected""") : Response.Write("")%>>Both</option>
</select>


So now the dropdown boxes stay on that selected name when I click the filter button but it goes back to the defaults when I page through the records. What can I try now?

Thanks
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 28, 2007 Aug 28, 2007
LATEST
sorry for bringing this back up but I still can figure out why when I page thru the records it keeps going back to the default value of the popup boxes? Can anyone help with this?

Thanks
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines