Question
I got the following from pattern 1 of
SearchPatternCookbook.
Pattern 1: Extract values from a table
Problem definition
Suppose there is a topic with a table defining entries in a TWikiForm. I.e. they define select menu items in a form template. They are then formatted like:
| *Name* | *Type* | *Tooltip message* |
| option1 | option | |
| option2 | option | |
| option3 | option | |
How to extract the 'name' values, i.e. 'option1', 'option2' and 'option3' and put them in a HTML form select input?
Solution
The following search pattern can be employed:
<form>
<select>
%SEARCH{ "^\|[^\|]*\| *option *\|" topic="%TOPIC%" type="regex" multiple="on" nosearch="on" nototal="on" format="<option>$pattern(^\| *(.*?) *\|.*)</option>" }%
</select>
</form>
which is, in effect:
My Concern
So far, so good, but the problem shows when the same search is applied in another table. The row where the above search is applied is not properly rendered by the table.
<form>
| *Name* | <input type="text" size="20" /> |
| *Option* | <select>
%SEARCH{ "^\|[^\|]*\| *option *\|" topic="%TOPIC%" type="regex" multiple="on" nosearch="on" nototal="on" format="<option>$pattern(^\| *(.*?) *\|.*)</option>" }%
</select> |
</form>
which is, in effect:
Environment
--
FredanLangam - 14 Nov 2007
Answer
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.
I got it. Just put
<select>,
%SEARCH% and
</select> together in one line and add
separator="" for the SEARCH.
<form>
| *Name* | <input type="text" size="20" /> |
| *Option* | <select>%SEARCH{ "^\|[^\|]*\| *option *\|" topic="%TOPIC%" type="regex" multiple="on" nosearch="on" nototal="on" format="<option>$pattern(^\| *(.*?) *\|.*)</option>" separator="<nop>"}%</select> |
</form>
which is, in effect:
--
FredanLangam - 14 Nov 2007