create new tag
, view all tags

Allowing Javascript extensions to TWikiForms

In developing TWikiApplications, it would occasionally be useful to extend the functionality of TWikiForm fields with a bit of javascript. A couple of examples of this include:

  • Validation check on a field
  • Auto-filling one field based on entry in another field. For example, I have 2 fields for a measurement, one for metric, one for imperial. It would be nice that if user fills in one field, the other is calculated automatically. (I have the javascript for this).

I have been learning how to do this in a regular html form but since TWikiForms are generated automatically from the associated form topic, I can't edit the actual form to insert the javascript.

Anyone have an idea how we could do this? I didn't submit this as a FeatureEnhancementRequest because I don't know how plausible it is.

-- Contributors: LynnwoodBrown - 13 Sep 2006


Hm, seems that there are already two existing solutions for parts of what you want. Compare Thomas' ControlsPlugin and Svens' new HtmlFormsPlugin. Both look very promissing.

-- FranzJosefSilli - 13 Sep 2006

Sorry if I wasn't very clear but those two plugins, while exciting, do not address what I'm talking about here. Both of those make it easier to create html forms for creating topics, custom searches etc. What I'm talking about it extending the functionality of how TWikiForms work when you are editing a topic that uses one.

-- LynnwoodBrown - 13 Sep 2006

Lynwood, that is a great idea, and if you could share the JS, maybe I'll find some chance to look at it. If you understand JS, I would love it if you could look at the JS that I stole for use in the ControlsPlugin. That is for computing field values dependent on a previous field value, but coming from a select. I am having the problem that this does not work when passing in URL parameters, in that case, the dependent selection does not succeed. I can explain more, if you are interested... (I am using this for form selections that are dependent on each other, but your suggestion is a generalization of that)...

On your question of feasibility... judging from what you write above, this sounds straightforward, assuming one has the JS (or an easy way to generate it)... but the precise answer will depend on the details of the requirements....

-- ThomasWeigert - 14 Sep 2006

Have a look at the BlogEntryForm of the BlogPlugin. It uses javascript to ease tagging.

-- MichaelDaum - 14 Sep 2006

Also have a look at WebTopicCreator that checks if the input field is a valid WikiWord.

To create a generalized form handling script derived from all our javascripts would be useful.

-- ArthurClemens - 14 Sep 2006

I'm apologize again that I don't seem to be getting across what I'm after here (except perhaps to Thomas). frown I'm not talking about javascript in normal html forms such as WebTopicCreator. I talking about using javascript directly in TWiki.TWikiForms so that the script works when when the form is displayed in edit mode.

Now, Michael's example is closer because BlogEntryForm does have javascript in it's definition, but it's only used as part the format attribute for a FormattedSearch. So the search results have some javascript in them but, still, that's not really extending the funcationality of the TWikiForm itself.

Thomas, here's the inpermial/metric conversion script I was looking at. Please understand, I don't know javascript other than what i've learned picking apart other scripts and a few minor form enhancements. My question is how can I add a script like this to a TWikiForm such that it works when the form is displayed in edit mode? Or, what would it take to make it possible/easier to add such scripts to TWikiForms? I will take at the script you use in ControlsPlugin. I looked at a lot of scripts of that sort trying to find one i could use and unfortunately found most too complicated for my use (or for me to understand sufficiently to modify to my use).

-- LynnwoodBrown - 14 Sep 2006

Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2006-09-15 - LynnwoodBrown
  • 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-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.