Tags:
create new tag
view all tags

Question

Hi,

Don't know if this is possible, but I've got a doc generator that uses an HTML form with a read-only text field called Concat, a hidden text field called topic and a submit button. A javascript returns a 'standardized' TWiki topic name to the Concat field and on submit, this value is assigned to topic, thereby becoming the name of the new topic and the topic is generated using the save script. Currently if the topic exists already, users are directed to existing topic. I need a check to see if topic exists and if yes, user is taken to a standard TopicExistsMessage topic. If not, then the new topic is created.

I'm using the following on submit call with a CALC to do this, which I'm guessing was not the original idea of the Spreadsheet plugin. On the other hand this does half work - the correct Concat value is assigned to the topic value if the EXISTS check returns false (which it always does because Concat is not recognized within the EXISTS check). So the second Concat.value reference is evaluated but the first reference within the EXISTS clause is not. Any advice please? Thanks!

<input type="submit" class="twikiSubmit" value="Create New Document Titled:" onclick="this.form.topic.value = %CALC{"$IF($EXISTS(this.form.Concat.value),'TopicExistsMessage', this.form.Concat.value)"}%;" / >

Environment

TWiki version: unspecified
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories:  

-- MichelleAlbertin - 25 Jul 2007

Answer

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.

The CALC is executed on the server side at page rendering time (from TML to HTML), and the onclick gets executed later at browser rendering time.

You can pass a onlynewtopic set to on URL parameter to prevent editing of existing topics. See TWikiScripts

-- PeterThoeny - 26 Jul 2007

Thank you Peter, that did the trick.

-- MichelleAlbertin - 26 Jul 2007

Change status to:
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2007-07-26 - 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.