SID-00156: How to Create a topic with a prefix using a form
| Status: |
Answered |
TWiki version: |
4.2.0 |
Perl version: |
5.8.8 |
| Category: |
CategoryEditing |
Server OS: |
SLES 10 SP1 |
Last update: |
16 years ago |
I'm trying to create a simple form that creates topics with typed input, but prefixed with a static name.
In my example, I was going to make a project tracking page that lists all topics that start with "Project" and have a form to create a topic with the prefix from the Project tracking topic.
Is this doable?
--
KarlSchafer - 04 Mar 2009
Discussion and Answer
Hi,
I have something similar that I quickly modified below that should help. You can add more fields or selects if you like:
<SCRIPT LANGUAGE="JavaScript">
<!-- Beginning of JavaScript -
function trim(stringToTrim) {
return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function MakeTopicName() {
var theenteredtopic=document.getElementById("enteredtopic")
var thetext="Project" + trim(theenteredtopic.value)
document.getElementById("topic").value=thetext
}
// - End of JavaScript - -->
</SCRIPT>
<form name="formmakenew" action="%SCRIPTURLPATH{edit}%/%WEB%/">
* Create a new New Product Intro page:<br> Type over the text below and give your new page a descriptive <nop>WikiWord name, then click *Create*: <br>
<input type="text" name="enteredtopic" id="enteredtopic" value="NewProductPage" size="26" />
<input type="hidden" name="topic" value="" />
<input type="hidden" name="topicparent" value="WebHome" />
<input type="hidden" name="onlywikiname" value="on" />
<input type="hidden" name="onlynewtopic" value="on" />
<input type="submit" class="twikiSubmit" onClick="MakeTopicName()" value="Create" />
</form>
--
KathyDeLaCruz - 05 Mar 2009
Thank you very much, I'll try it out!
--
KarlSchafer - 05 Mar 2009
I've tried this, and I keep getting warnings that "WebHome" already exists. I'm not sure what part of this is setting the topic name to
WebHome; The layout of this seems logical enough.
--
KarlSchafer - 05 Mar 2009
Hmmm ... this works on mine ... but when you're on the page where it says Webhome already exists, can you look in the url and see if you see any variables are being populated? (for example, if you've got something like ?topic=xxxxx or if they are blank?
Also, you can try using the
OnSubmit event instead of
OnClick, and then add the line
return true;
to the end of the function
MakeTopicName
--
KathyDeLaCruz - 05 Mar 2009
Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the
TWiki consultants if you need timely help. We invite you to
get involved with the community, it is more likely you get community support if you support the open source project!
--
PeterThoeny - 2009-04-17
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.