You are here:
TWiki
>
Support Web
>
GenerateOptionsListFromOptionsForm
(2007-11-13,
JohnPoplett
)
(raw view)
Tags:
tag this topic
create new tag
,
view all tags
---++ Question I am working on a training log application and use select controls throughout. I took the advice of the forms documentation and create tables that can be used to generate select lists for TWiki forms. I also want to use these same tables for HTML forms. The TWiki documentation recommends creating tables for this purpose in this format: <verbatim> | *Name* | | NoDisclosure | | Public Supported | | Public FAQ | </verbatim> | *Name* | | NoDisclosure | | Public Supported | | Public FAQ | I have so far had no luck in writing a search that would extract the contents of the columns minus the header column. Here is my best attempt so far: <verbatim> | Exercises: | <select size="1" name="WeightRoomExercises"> %SEARCH{"\|\s*[a-z0-9]*.*" topic="WeightRoomExercises" type="regex" multiple="on" nonoise="on" format="<option>$pattern(^\|\s*([a-z0-9\s\(\)]*?[a-z0-9\(\)])\s*\|.*)</option>"}% </select> | </verbatim> The problem with the foregoing are: * creates an empty =<option></option>= pair for the header column * puts each =<option></option>= pair on a separate line The table I use looks like this: | *Name* | | Leg Press | | Abductors | | Quads | | Mule Kick | | Leg Curls | | Rotary Hip (pull) | | Rotary Hip (push) | | Calf Raises | | Lat Pull Downs | | Seated Rows | | Chest Press | | Upright Row | | Crunches | The result of this search is: <verbatim> <input disabled="disabled" type="hidden" name="topic" size="70" value="WeightRoomExercise00001DetailAUTOINC00" /> | Exercise: | <select size="1" name="WeightRoomExercises"> <option></option> <option>Leg Press</option> <option>Abductors</option> <option>Quads</option> <option>Mule Kick</option> <option>Leg Curls</option> <option>Rotary Hip (pull)</option> <option>Rotary Hip (push)</option> <option>Calf Raises</option> <option>Lat Pull Downs</option> <option>Seated Rows</option> <option>Chest Press</option> <option>Upright Row</option> <option>Crunches</option> </select> | </verbatim> Consequently, TWiki rendering does not see the result as a line in a TWiki table. I know how to parse this in Perl but so far have not been able to coax =var%SEARCH= to do my bidding. I am aware of similar examples in the =SearchCookBook= but these don't quite fit the bill. ---++ Environment %EDITTABLE{format="|label,1|text,70|" changerows="off"}% | TWiki version: | Codev.TWikiRelease04x01x02 | | TWiki plugins: | Plugins.DefaultPlugin, Plugins.EmptyPlugin, Plugins.InterwikiPlugin | | Server OS: | Mac OS X | | Web server: | Apache | | Perl version: | 5.8.6 | | Client OS: | Mac OS X | | Web Browser: | Camino | | Categories: | Forms %SUPPORTCATEGORIES% | -- Main.JohnPoplett - 11 Nov 2007 ---++ Answer %STATUS_REMINDER% your regex should work with: <verbatim> | Exercises: | <select size="1" name="WeightRoomExercises"> %SEARCH{"\|\s*[a-z0-9]*.*" topic="WeightRoomExercises" type="regex" multiple="on" nonoise="on" format="<option>$pattern(^\|\s*([a-z0-9\s\(\)]*?[a-z0-9\(\)])\s*\|.*)" separator="</option>"}% </select> | </verbatim> | Exercises: | <select size="1" name="WeightRoomExercises"> %SEARCH{"\|\s*[a-z0-9]*.*" topic="%TOPIC%" type="regex" multiple="on" nonoise="on" format="<option>$pattern(^\|\s*([a-z0-9\s\(\)]*?[a-z0-9\(\)])\s*\|.*)" separator="</option>" newline="%BR%"}% </select> | Others will help you with filtering the headers more clearly. -- Main.FranzJosefGigler - 11 Nov 2007 Hi, Franz! Thanks for your suggestion! I had overlooked the separator parameter. I understand better why I get a blank first option. The regex in the plain string in a =varSEARCH= is a topic selector! It doesn't select text within a topic. The regex pattern in =$pattern= selects text within a topic. My =$pattern= regex results in an empty string for the first line. It would be nice if there was an option so the format string is only emitted when the result of the pattern regex is non-empty. Anyway, I am getting usable results now. Thanks again. John -- Main.JohnPoplett - 12 Nov 2007 %COMMENT{type="supportquery"}%
WebForm
SupportStatus
AnsweredQuestions
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r4
<
r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r4 - 2007-11-13 - 04:11:21 -
JohnPoplett
Log In
or
Register
Support Web
Support guidelines
Ask a question
Open questions
My recent questions
Search
Changes
(
major only
)
RSS Feed
Notifications
Register
TWiki 4.3.2
Known issues
Bugs database
Support questions
Help answering new questions
Get quick help in #twiki IRC channel
Suggestions
Create feature request
Webs
Blog
Codev
Main
Plugins
Sandbox
Support
TWiki
TWiki01
TWiki02
TWiki03
TWiki04
TWiki04x01
TWiki04x02
TWiki04x03
Twiki, Inc.
Support
share:
E
dit
A
ttach
Ideas, requests, problems regarding TWiki?
Send feedback
Copyright © 1999-2010 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.