SID-00241: Populate a drop down list from a table within a topic
| Status: |
Answered |
TWiki version: |
4.2.3 |
Perl version: |
|
| Category: |
CategoryForms |
Server OS: |
|
Last update: |
16 years ago |
I'm trying to populate a drop down list much like the one found on the support page (
http://twiki.org/cgi-bin/view/Support
). Below is the code from that page that I'm having difficulty understanding:
Search by category:
<select name="topic"> %CALC{$LISTJOIN($sp, $LISTMAP(<option value='$item'>$PROPERSPACE($item)</option>, $GET(cat)))}% </select>
I use a drop down menu within a form and take the entries from a table within a topic. The form row is:
| SpecCategory | select | 1 | | Specification Category | |
Now I would like to do the same except not within a form. Could someone kindly explain the above formula using %CALC% or if there's an alternate way of doing this that would also be appreciated.
--
JaniHamalainen - 01 Apr 2009
Discussion and Answer
Perhaps some excessive indenting makes it clearer. I assume it's the TWiki markup that confuses you, not the HTML, so I've also annotated that a bit. If you are still confused, then by what part? (i.e., which line number?)
| 1 |
<select name="topic"> |
HTML |
| 2 |
%CALC{ |
Calls SpreadSheetPlugin |
| 3 |
$LISTJOIN($sp, |
This SpreadSheetPlugin function joins all the <option>...</option> tags with a space. In fact it isn't necessary here, because HTML ignores white space between tags. |
| 4 |
$LISTMAP( |
Think of this is 'for each item in the list $GET(cat) ' |
| 5 |
<option value='$item'> |
the raw value of $item |
| 6 |
$PROPERSPACE($item) |
a function to change "WikiWords" into more familiar "Spaced Words" |
| 7 |
</option> |
|
| 8 |
, $GET(cat)) |
GET the value of the variable 'cat' (which must have been 'SET' earlier in the same topic. |
| 9 |
) |
|
| 10 |
}% |
|
| 11 |
</select> |
HTML |
--
SeanCMorgan - 02 Apr 2009
Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the
TWiki consultants if you need timely help. We invite you to
get involved with the community, it is more likely you get community support if you support the open source project!
--
PeterThoeny - 2009-06-02
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.