Tags:
create new tag
view all tags

SID-00089: Combining QuerySearch with form parameters

Status: Answered Answered TWiki version: 4.2.3 Perl version:
Category: CategorySearch Server OS: Last update: 16 years ago

Hi - I want to have a form that drives a query search which looks for values in pages having form fields - and I'm having problems. Below is a version of what I want to do - can someone help as to why this isn't working? Message is (excess operators =). Thanks.

%<nop>SEARCH{
search="MyForm[name='MyField'].value = %<nop>URLPARAM{"search" encode="quote"}%" type="query"
}%

<form id="MySearchForm" action="%<nop>SCRIPTURLPATH{view}%/%INCLUDINGWEB%/%INCLUDINGTOPIC%">
Enter search string:&nbsp;<input type="text" name="search" value="%<nop>URLPARAM{ "search" encode="entity" }%" size="30" />
</form>

-- StephenHallett - 06 Feb 2009

Discussion and Answer

1. You are comparing the value of you form field to a string, e.g. you need to quote the string:
search="MyForm[name='MyField'].value = '%URLPARAM{"search" encode="quote"}%'"

2. Don't <nop> the URLPARAM in the input field.

-- PeterThoeny - 07 Feb 2009

Peter - great, many thanks for swift answer - that does the job. Have I missed, or could I suggest an example page somewhere laying out worked examples of directing searches on form fields using all the different input types (textbox, radio, combo etc).

-- StephenHallett - 07 Feb 2009

We have a SearchPatternCookbook and a QuerySearchPatternCookbook. Please feel free to add examples there.

-- PeterThoeny - 08 Feb 2009

[Cookbooks won't allow my edits - so here is worked example:]

The code below searches through two named fields in all topics having form 'MyPageForm'. A user-form has input boxes for the search strings. The page calls itself recursively with results output to a table.

<noautolink> 
<form>
action="%SCRIPTURLPATH{view}%/%INCLUDINGWEB%/%INCLUDINGTOPIC%">
Field One: <input type="text" name="search_field_one" value="%URLPARAM{ "search_field_one" encode="entity" }%" size="15" /><br />
Field Two: <input type="text" name="search_field_two" value="%URLPARAM{ "search_field_two" encode="entity" }%" size="15" /><br />
<input type="submit" name="search_submit" value="Search">
</form>
</noautolink>

| *Page Link* | *Field One* | *Field Two* | *Field Three* | *Field Four* |
%SEARCH{
search="(lc(MyPageForm[name='FieldOne'].value) ~ lc('%URLPARAM{"search_field_one" encode="quote"}%') AND 
lc(MyPageForm[name='FieldTwo'].value) ~ lc('%URLPARAM{"search_field_two" encode="quote"}%'))"
type="query"
limit="150"
excludetopic="Web*" 
order="formfield(FieldOne),formfield(FieldTwo)"
nonoise="on"
format="| [[$topic]] | <i><b> $formfield(FieldOne)</b></i> | $formfield(FieldTwo) | $formfield(FieldThree) | $formfield(FieldFour) |"
}%

-- StephenHallett - 08 Feb 2009

Oops, sorry. You have now access. Dummy me, yesterday I already added you to the TWikiCommunityGroup but forgot the save the page smile

-- PeterThoeny - 08 Feb 2009

Thanks - example posted also to QuerySearchPatternCookbook (updated example)

-- StephenHallett - 13 Feb 2009

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Answered
Title Combining QuerySearch with form parameters
SupportCategory CategorySearch
TWiki version 4.2.3
Server OS

Web server

Perl version

Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r8 - 2009-02-13 - StephenHallett
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.