SID-00754: Compose topic name from form data
| Status: |
Answered |
TWiki version: |
4.3.1 |
Perl version: |
5.8.2 |
| Category: |
CategoryAPI |
Server OS: |
AIX 5.3 |
Last update: |
16 years ago |
I want to create a topic name from fields entered in a form. Simplest case: for input field 1, person types "X", and for input field 2, person types "Y". They hit go, and topic XY gets created.
I've seen various recommendations like "use Javascript" or "auto gen the topic, and populate data in form fields". Some of those recommendations are pretty old, and I wanted to know if there was any more recent updates? I have a topic template that I use. So, is there something I can put form-side to gen the "topic" parameter (I guess it would have to be javascript), or is there something I can put in my template which would say "when you use this template, generate the topic name from variables A+B"? Should I be gravitating toward using the COMMENT plugin for this?
Thanks for your patience.
Aaron
--
AaronLWalker - 2010-02-12
Discussion and Answer
At this point, I'm going with the javascript approach:
<script language="JavaScript"><!--
function textBuild() {
var tbtemp = new String('Cust' + document.newtopic.customerlocation.value + document.newtopic.customername.value);
tbtemp = tbtemp.replace(/[^a-zA-Z 0-9]+/g,'');
document.newtopic.topic.value = tbtemp;
}
//--></script>
---+++ Create New Customer
<form name="newtopic" action="%SCRIPTURLPATH{"edit"}%/%WEB%/" onSubmit="textBuild()">
<input type="hidden" name="templatetopic" value="OpsCustomerTemplate" />
<input type="hidden" name="redirectto" value="%TOPIC%" />
<input type="hidden" name="topic" />
| Customer Name | <input type="text" size="16" name="customername" /> |
| Customer Location | <select name="customerlocation"><option value="US"\>US</option> <option value="CN"\>Canada</option></select> |
<input type="submit" class="twikiSubmit" value="Create" />
<input type="hidden" name="onlynewtopic" value="on" />
</form>
--
AaronLWalker - 2010-02-12
That is a good way to go.
Consider a full
TWikiForms based application where you push Country and Customer name into form fields. That brings you the flexibility to slice and dice your data with
QuerySearch and
FormattedSearch. In this case you can use autogenerated topuc names. For inspiration, the support forum here does that.
--
PeterThoeny - 2010-02-12
Marking as answered.
--
AaronLWalker - 2010-02-16
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.