Tags:
create new tag
view all tags

SID-00754: Compose topic name from form data

Status: Answered 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

      Change status to:
ALERT! 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.
SupportForm
Status Answered
Title Compose topic name from form data
SupportCategory CategoryAPI
TWiki version 4.3.1
Server OS AIX 5.3
Web server IBM HTTP 7
Perl version 5.8.2
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2010-02-16 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.