The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Add a form on creation of a new topic

Go down

Tutorial Add a form on creation of a new topic

Post by Ange Tuteur 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 :

 
form - Add a form on creation of a new topic Captu375

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.

form - Add a form on creation of a new topic Captu376

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]:');
    }
});



form - Add a form on creation of a new topic Captu377

form - Add a form on creation of a new topic Icon_exclaim 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
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Back to top


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