The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Add a form on creation of a new topic

View previous topic View next topic Go down

Add a form on creation of a new topic

Post by Ange Tuteur on March 24th 2014, 9:02 am

Add a form on creation of a new topic



This tutorial will allow you to setup a form for your members to fill out on your Forumotion forum. The form will automatically be added to the editor when creating a new topic in a specific forum, just like on the support forum :



This should work for all forum versions, as long as you're using the default editor.


Adding the javascript
Go to Administration Panel ► Modules ► Javascript codes management ► Create a new script.

Title : Automatic form
Placement : In all the pages
Paste the code below and save :


Code:
$(function() {
if (location.pathname == '/post' && location.search == '?f=FORUM_ID&mode=newtopic') {
$('#text_editor_textarea').val('FORM');
}
});

Modifying the code :
For this to work, you must first make some changes. You must replace FORUM_ID with the ID of the forum you want this to work in. This ID can be seen from the address bar while in a forum.


You must replace FORM with the fields you want to insert into the editor. You should write your form fields between the single quotes in val().

Special characters to use :

\n : Use this escape sequence to insert a line break.
\" : Use this escape sequence to insert a double quote.
\' : Use this escape sequence to insert a single quote.

When finished you should have an automatic form at topic creation for your members to fill out.


Code:
$(function() {
if (location.pathname == '/post' && location.search == '?f=1&mode=newtopic') {
$('#text_editor_textarea').val('[b]Field 1[/b]:\n[b]Field 2[/b]: Don\'t fill this field in\n[b]Field 3[/b]:');
}
});




Attention :
Line breaks must be written as \n otherwise you risk breaking the script.

The quote escape sequences should be used when writing double quotes inside double quotes and vice versa. Failure to do so will cause the string to close early and break the script.



Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2684
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum