This topic is locked

Get a user-input parameter for list Query

2/9/2010 5:21:09 PM
ASPRunnerPro General questions
P
paulwebb author

I want to give the user the option to "Include Closed" records on mysearchpage_list

(usually accessed via Default 'QuickJump' menu; no records on first page)
I know how to do this with a 'WhereAdd' in 'BeforeQueryList' - but how do I get the User Input?

(WhereAdd 'closed=0' if "Include Closed" not selected)
I'd like to prompt the user to choose "Include Closed" (Y/N) on the page, or as the page is selected, then the Search to work on this selection.
I thought I could make a 'mysearchpagelistsetting' page/table with one record/field, direct 'QuickJump' to mysearchpagelistsetting_edit, Redirect from there to mysearchpage_list with a Session variable set.

  • but I'm sure these is a much BETTER way?
    Ideally, I guess I want an "Include Closed" checkbox (default unchecked) in "Search for:" area at top of list page - I guess 'Search' re-queries, so the WhereAdd will be reprocessed?
    That would also allow the user to change "Include Closed" choice and re-search on the page
    Still on 6.1 - I need to complete this project before moving to 6.2

Sergey Kornilov admin 2/9/2010

You can add a checkbox to the form using Visual Editor in HTML mode:

<input type="checkbox" name="include" value="yes">Include closed?


Then in any event you can access this checkbox value as $_POST["include"] i.e.

if ($_POST["include"]=="yes")

{

...

}
P
paulwebb author 2/22/2010

Thanks - I've now learnt how to add check box (and other types) to my form.
As I'm in ASP not PHP, I think you meant: Request.Form("include")...

rather than: ($_POST["include"]=="yes")...
Now I'm stuck as to how to capture this in events, as it seems to be too transient - ie, it's not available to any events in list pages??
Is there any way to capture it in list page before/when hitting 'search'?

I also would like to get it in advanced search

P
paulwebb author 2/26/2010

Looking for some help here guys!

Sergey Kornilov admin 2/27/2010

Request.Form("include") is a proper way access form element named 'include'.
More info:

http://www.aspwebpro.com/tutorials/asp/passvariableswform.asp

P
paulwebb author 2/27/2010

I understood that already - how do I keep this in the search on list form?

Sergey Kornilov admin 2/27/2010

Request.Form("include") will be accessible in all list page events.

P
paulwebb author 3/7/2010

I need to frame this problem more precisely:
I have now learnt how to add checkbox, and read it (Thanks), and that works fine on, as example, an edit page - because I can get the checkbox value in BeforeAdd event.
There seems no suitable event in list page to capture Request.Form("include")
I want to capture this to change the SQL when user hits 'search'
Do I need to use a different method to capture/save the checkbox status so it can be used in the 'search'?

Sergey Kornilov admin 3/8/2010

Request collection is available in all events. If you are not able to access Request.Form("include") variable you probably placing this check box at the wrong place. It needs to be inside the search form.
The best event to adjust SQL query is BeforeSQLQuery.