Is it possible to dynamically populate a drop down in a table (its a twiki page with table entries) which has one of its field with property as select?
I have gone through the plugin
EditTablePlugin but it talks about static values in dropdown.
Any thoughts?
Thanks
--
PrathibaRao - 01 Jul 2008
If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.
You can create a search that creates a comma-separated list and feed that to the format parameter of EditTablePlugin.
--
ArthurClemens - 01 Jul 2008
--
PrathibaRao - 02 Jul 2008
I have gone through the variable VARSEARCH and its parameters.But i dont seem to find any parameter that will help me create a comma separated list. Is there is any search that i have missed out.Any knid of example or pointers will also help..
Thanks
--
PrathibaRao - 02 Jul 2008
The comma separated list will again be a static values. It has to be dynamic i.e initially dropdown will have values .When the value is not present then we should b able to add a value and on refresh the value has to be added to the dropdown .Is that possible?
--
PrathibaRao - 02 Jul 2008
I have a form that prepopulates values into a drop down using a
SEARCH and an
IF statement (TWiki/IfStatements), which I use to assign tasks to members of different development teams. The
SEARCH sets a variable to a comma separated list of the values I want (e.g., wiki names called
TEAM_MEMBERS). The
IF statement checks to see if
TEAM_MEMBERS is set: if it is, I use
ForEachPlugin to loop through and make drop-down options; if not, I just output a text box where the user can type in the value.
That only works at load time. If you need something AJAX-y, you may want to look at
AutoCompletePlugin. I'm playing with that as well, but finding bugs :-/
--
AaronFuleki - 02 Jul 2008
Yes I use the
EditTablePlugin which contains a select input box the value of which is defined by a
SEARCH statement.
The table below is one I use to contain details about databases and it allows the user to select the database server from a dynamically populated select box.
%EDITTABLE{format="| select, 1, , Ingres, Microsoft SQL Server, Oracle, Progress | text, 20 | select, 1, , %SEARCH{ ".*?" topic="Servers" type="regex" multiple="on" nonoise="on" expandvariables="on" format="$pattern(^\| *(.*?) *\|.*)" separator="," }% | text, 10 | textarea, 5x20 | textarea, 5x20 |" changerows="on"}%
| *Database Software* | *Database Name* | *Database Server* | *DB Server Version* | *System Users/Passwords* | *Database Patches* |
The table above takes its list of possible servers from a topic I called Servers. The topic Servers is itself a dynamically generated table with one column and no header, i.e. it looks like this:
|
|
| UnixServer1? |
| WindowsServer4? |
| Solarisbox7 |
|
|
|
but it actually uses the
DatabasePlugin to get the list of servers from a database (in my case an Oracle 10g Express database):
%DATABASE_SQL{description="interfaces_database" sql="SELECT DISTINCT name FROM SERVER ORDER BY name ASC" format="| $NAME |"}%
The values of the select input box within the
EDITTABLE statement is therefore dynamically based upon another dynamically generated topic. I could not get the regex working for a Servers topic that contained a header that looked like the following but its not important:
You dont have to use the
DatabasePlugin? to populate the Servers topic for example. It could just be static.
--
JamesGMoore - 03 Jul 2008
Thanks for the help James. But my concern is if it is static then if i want to add new value , each time i need to add that value in the topic ,so that it gets reflected dynamically in another topic.Is it not possible that ,first time the select box is empty,then user adds the value .Then that value is present in the drop down.In this way dropdown keeps on growing dynamically... Is that possible???
--
PrathibaRao - 03 Jul 2008
Hmm I think that you are asking a lot! So you want a form that has a select box and a text box. If the select box does not contain a value you are looking for you can type a new value in the text box then click submit to add the value to the select box?
If so then I guess you need to start looking at the
TWiki Scripts. You already know how to populate a select box from another topic. All you need to find out now is how to add another row to that other topic where the values for the select box are stored. I am imagining a form where the action=somescript where somescript is possibly a custom script that adds the
%FORMFIELD{ "nameoftextbox" )% to the select box's source topic. Not sure if you can use an EDITTABLE for the form though. You would probably have to use the html code for a html form instead. Unfortunately I've never made a custom
TWikiScript? so I cannot help you with that sorry.
--
JamesGMoore - 04 Jul 2008
isnt there any other way to implement this???
--
PrathibaRao - 07 Jul 2008
Your application sounds a lot like mine!
Take a look at
ExtractedValuesFromATable
--
SeanCMorgan - 11 Jul 2008
Hi Sean... if the listed options are not the ones that user wants to select ,is it possible to add value i.e make the select as text box when you want to add new values and that value becomes one of the listed options .
--
PrathibaRao - 15 Jul 2008
>
i.e make the select as text box
Do you mean you want to dynamically make the select dropdown change into a text box? I suppose that's possible, but it would be confusing to the users. Why not just have two separate controls, a dropdown
and a text box? This would be similar to paper-based forms that do that with an option like "Other (please specify)". But to do that in HTML would require a custom application.
I might be getting confused as to what you are asking for, so let me break this down a bit and you can confirm or correct my assumptions:
- There can be zero or more existing entries.
- The existing entries are displayed as a select/option box (like the "Change status to" box, below).
- In addition, the form should have a text box to allow the user to add an entry so as to extend the list of existing entries.
I don't think this can be done with
TWikiForms because, as it says in that topic, "a form is to a web as a table is to a database". In other words, the form definition is like a data dictionary (which is why the values are static).
However, you can do this with an HTML form that you create (you lose the ability to do FORMFIELD lookups, but can do something similar with SEARCH, as already mentioned in
ExtractedValuesFromATable). There would be a text box in a separate HTML form (it could be right beside the first field), with a separate submit button (labeled something like "Add a new option"). The options would still be maintained in a table, and the "Add a new option" button appends the new entry to the table. The table of existing select options would not be visible on the form (it's either in another topic, or hidden inside HTML comment marks). The submit automatically refreshes the page, and so the dropdown will be automatically extended. You do that with the
CommentPlugin:
- To add the entry to a table, see the tableappend template.
- If you want the table of valid entries to be on a different topic (so it can be shared between multiple topics) see the return template.
--
SeanCMorgan - 15 Jul 2008
Closing this question after more than 30 days of inactivity. Feel free to re-open if needed.
--
PeterThoeny - 02 Sep 2008