vForums Support Banner



 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Database of Codes/Hacks/Mods :: Predefined Posting Template/Form - View Topic (Page 1 of 5)Page: 1 2 3 4 5
Topic Rating: *****
Printable View
Ross
Administrator
*****

[Avatar]

Posts: 3,708
Status: Offline
Gender: Male
Age: 7 14
Joined:  

Additional Groups:
Support Team
***


Reputation: 45%  


pmwwwtwittergtalkvForum
Predefined Posting Template/Form (26th Nov 07 at 11:59pm UTC)
This code can be used to give users a custom posting form in order to ensure they provide certain information when posting. Common uses of this include graphics request forms and RPG character creation.

The code should be placed in the footer of the board you wish to use it on. To do this, go to the "Headers and Footer" section of your admin panel found in the "Site Design" section. From this page you can select the board you wish to use it on and press "continue" so you are presented with the text areas representing the header and footer of your forum.

Code:
 
  1. <script type="text/javascript">
  2. <!--
  3. /* Predefined Posting Template/Form
  4.     Created by Ross of vForums
  5.     http://virtualforums.co.uk
  6.     Please do not repost outside of
  7.     vForums support without permission */
  8. var _title = 'New Code Request';
  9. var _description = 'Please ensure you have a read of the <a href="URL">Rules</a> before posting';
  10. var _fields = new Array(); var _f = 0;
  11.     _fields[_f++] = new Array('input', 'Description', ['size', 40, 'maxLength', 50], '', 'Please give a short description of what it is you\'re after. Include any relevant keywords.', false);
  12.     _fields[_f++] = new Array('select', 'Type', false, ['All Pages', 'Main Page', 'Mini-Profile', 'Info Center', 'Private Messaging', 'Profile', 'Posting', 'Thread Listing', 'Welcome Table', 'Other'], 'Select the category/area that best fits the type of code you\'re after.', true);
  13.     _fields[_f++] = new Array('input', 'Example', ['size', 40, 'maxLength', 200], false, 'If you have an example of what you want to achieve, please link to it here. This can be anything from an image of what you need to a link to a forum using the code you want.', false);
  14.     _fields[_f++] = new Array('textarea', 'Request Details', ['cols', 40, 'rows', 10], false, 'Please give as much information as possible about your request. The more information you give now, the easier it will be for someone to fill your request.', true);
  15. var _widths = ['100%', '20%', '40%', '40%'];
  16. var _posting_form = {
  17.     errors: new Array(),
  18.     init: function() {
  19.         this.create_form();
  20.     },
  21.     
  22.     create_form: function() {
  23.         // Create new post layout
  24.         var _holder = document.createElement('table');
  25.         _holder.setAttribute('className', 'border');
  26.         _holder.setAttribute('class', 'border');
  27.         _holder.setAttribute('cellSpacing','1');
  28.         _holder.setAttribute('cellPadding', '4');
  29.         _holder.setAttribute('align', 'center');
  30.         _holder.setAttribute('width', _widths[0]);
  31.         _holder.setAttribute('id', 'post_form_holder');
  32.         _holder.appendChild(document.createElement('tbody'));
  33.         _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  34.         _holder.firstChild.lastChild.lastChild.className = 'title1';
  35.         _holder.firstChild.lastChild.lastChild.colSpan = '3';
  36.         _holder.firstChild.lastChild.lastChild.lastChild.size = '2';
  37.         _holder.firstChild.lastChild.lastChild.lastChild.appendChild(document.createTextNode(_title));
  38.         if(_description) {
  39.             _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  40.             _holder.firstChild.lastChild.lastChild.setAttribute('className', 'window1');
  41.             _holder.firstChild.lastChild.lastChild.setAttribute('class', 'window1');
  42.             _holder.firstChild.lastChild.lastChild.setAttribute('colSpan', '3');
  43.             _holder.firstChild.lastChild.lastChild.lastChild.setAttribute('size', '2');
  44.             _holder.firstChild.lastChild.lastChild.lastChild.innerHTML = _description;
  45.         }
  46.         
  47.         for(_f=0; _f<_fields.length; _f++) {
  48.             switch(_fields[_f][0]) {
  49.                 case 'textarea' :
  50.                     var _tmp = document.createElement('textarea');
  51.                 break;
  52.                 
  53.                 case 'select' :
  54.                     var _tmp = document.createElement('select');
  55.                     for(_o=0; _o<_fields[_f][3].length; _o++) {
  56.                         _tmp.options[_o] = new Option(_fields[_f][3][_o], _fields[_f][3][_o]);
  57.                     }
  58.                 break;
  59.                 
  60.                 default :
  61.                     var _tmp = document.createElement('input');
  62.                     _tmp.type = 'text';
  63.                     if("undefined" != typeof _fields[_f][3] && _fields[_f][3] != "")
  64.                         _tmp.setAttribute('value', _fields[_f][3]);
  65.                 break;
  66.             }
  67.             _tmp.setAttribute('id', _f);
  68.             if("undefined" != typeof _fields[_f][2] && _fields[_f][2].length > 0) {
  69.                 for(_a=0; _a<_fields[_f][2].length; _a++) {
  70.                     _tmp.setAttribute(_fields[_f][2][_a++], _fields[_f][2][_a]);
  71.                 }
  72.             }
  73.             var _class = 'window' + ((_f % 2 == 0)? '2' : '1');
  74.             var _row = document.createElement('tr');
  75.             _row.appendChild(document.createElement('td'));
  76.             _row.lastChild.setAttribute('class', _class);
  77.             _row.lastChild.setAttribute('className', _class);
  78.             _row.lastChild.setAttribute('vAlign', 'top');
  79.             _row.lastChild.setAttribute('width', _widths[1]);
  80.             _row.lastChild.appendChild(document.createElement('font'));
  81.             _row.lastChild.lastChild.setAttribute('size', '2');
  82.             _row.lastChild.lastChild.style.fontWeight = 'bold';
  83.             _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][1] + ':'));
  84.             _row.appendChild(document.createElement('td'));
  85.             _row.lastChild.setAttribute('class', _class);
  86.             _row.lastChild.setAttribute('className', _class);
  87.             _row.lastChild.setAttribute('width', _widths[2]);
  88.             _row.lastChild.appendChild(document.createElement('font'));
  89.             _row.lastChild.lastChild.setAttribute('size', '2');
  90.             _row.lastChild.lastChild.appendChild(_tmp);
  91.             _row.appendChild(document.createElement('td'));
  92.             _row.lastChild.setAttribute('class', _class);
  93.             _row.lastChild.setAttribute('className', _class);
  94.             _row.lastChild.setAttribute('vAlign', 'top');
  95.             _row.lastChild.setAttribute('width', _widths[3]);
  96.             _row.lastChild.appendChild(document.createElement('font'));
  97.             _row.lastChild.lastChild.size = '1';
  98.             _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][4]));
  99.             _holder.firstChild.appendChild(_row);
  100.         }
  101.         var _submit = document.createElement('tr');
  102.         _submit.appendChild(document.createElement('td'));
  103.         _submit.lastChild.setAttribute('class', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  104.         _submit.lastChild.setAttribute('className', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  105.         _submit.lastChild.setAttribute('align', 'center');
  106.         _submit.lastChild.setAttribute('colSpan', 3);
  107.         var _button = document.createElement('input');
  108.         _button.setAttribute('type', 'button');
  109.         _button.setAttribute('value', 'Post Message');
  110.         _button.onclick = function() { _posting_form.post_it(); };
  111.         _submit.lastChild.appendChild(_button);
  112.         _holder.firstChild.appendChild(_submit);
  113.         document.post_form.style.display = 'none';
  114.         document.post_form.parentNode.insertBefore(_holder,  document.post_form);
  115.     },
  116.     
  117.     post_it: function() {
  118.         // create message and attempt to post it
  119.         this.errors = new Array();
  120.         document.post_form.message.value = document.post_form.subject.value = '';
  121.         var _sub = document.getElementById('0').value;
  122.         _fields[0][5] = true;
  123.         document.post_form.subject.value    = _sub;
  124.         for(_f=0; _f<_fields.length; _f++) {
  125.             if(document.getElementById(_f)) {
  126.                 _value = document.getElementById(_f).value;
  127.                 if(!_value || _value.match(/^s*$/)) {
  128.                     if(_f > 0 && _fields[_f][5])
  129.                         this.show_error('You have left the ' + _fields[_f][1] + ' option empty. This is a required field and as such must contain a value.');
  130.                     else
  131.                         _value = 'None';
  132.                 }
  133.                 document.post_form.message.value += '' + _fields[_f][1] + ': ' + _value + '\n\n';
  134.             }
  135.         }
  136.         if(this.errors.length == 0)
  137.             document.post_form.post.click();
  138.         else
  139.             this.show_error();
  140.     },
  141.     
  142.     show_error: function() {
  143.         if("undefined" != typeof arguments[0] && arguments[0]) {
  144.             this.errors.push(arguments[0]);
  145.         } else {
  146.             // Show Errors
  147.             if(document.getElementById('status_holder')) {
  148.                 document.getElementById('status_holder_title').innerHTML = "An Error Has Occured";
  149.                 document.getElementById('status_holder_message').innerHTML = this.errors.join("<br />");
  150.                 document.getElementById('status_holder').style.display = 'block';
  151.             }
  152.         }
  153.     }
  154. }
  155. if(document.post_form && location.href.match(/action\/post\/?$/) && vf_username != 'Guest') {
  156.     _posting_form.init();
  157. }
  158. //-->
  159. </script>
 





Editing the Code
The following sections are the parts of the code that should be edited to suit your application of the code:
var _title = 'New Code Request'; // the name of your form

var _description = 'Please ensure you have a read of the <a href="URL">Rules</a> before posting'; // this is the description of the form telling users what to do

var _fields = new Array(); var _f = 0; // See below for editing instructions on this section
 _fields[_f++] = new Array('input', 'Description', ['size', 40, 'maxLength', 50], '', 'Please give a short description of what it is you're after. Include any relevant keywords.', false);
_fields[_f++] = new Array('select', 'Type', false, ['All Pages', 'Main Page', 'Mini-Profile', 'Info Center', 'Private Messaging', 'Profile', 'Posting', 'Thread Listing', 'Welcome Table', 'Other'], 'Select the category/area that best fits the type of code you're after.', true);
_fields[_f++] = new Array('input', 'Example', ['size', 40, 'maxLength', 200], false, 'If you have an example of what you want to achieve, please link to it here. This can be anything from an image of what you need to a link to a forum using the code you want.', false);
_fields[_f++] = new Array('textarea', 'Request Details', ['cols', 40, 'rows', 10], false, 'Please give as much information as possible about your request. The more information you give now, the easier it will be for someone to fill your request.', true);


var _widths = ['100%', '20%', '40%', '40%']; // These are the widths of each box. You may need to alter them to prevent lines being streyched if you use a thin width.

 
The parts highlighted in red are the actual posting fields. There are 3 types of field you can use, an example of each is given below where:

The blue parts are the attributes for this field, unless you know HTML it's probably best to leave them as they are.
The purple true/flase sets if the field is a required field or not (false means it can be left blank).

You can list as many different fields as necessary where shown above. The first field will always be the subject of the posted message. Some general rules to remember when editing these fields are that you cannot place an apostrophe in any of the fields without first escaping it with a backslash '. Also, you cannot put in any line breaks/returns by pressing the enter key, to insert a new line into a description use <br />

Single Line Input:
_fields[_f++] = new Array('input', 'Field Name, ie. "Character Name" or "Description"', ['size', 40, 'maxLength', 50], 'Default Value filled in when the form loads. Can be left blank', 'A short description of what the field is for', false);


Drop down menu:
_fields[_f++] = new Array('select', 'Field Name, ie. "Gender" or "Type"', [], ['All Pages', 'Main Page', 'Mini-Profile', 'Info Center', 'Private Messaging', 'Profile', 'Posting', 'Thread Listing', 'Welcome Table', 'Other'], 'A short description of what the field is for.', true);

Here, the red represents the different options. Each option should be wrapped in single quotation marks (') and seperated by a comma (,)


Multiple-Line Text Area:
_fields[_f++] = new Array('textarea', 'Field Name, ie. "History" or "Further Details"', ['cols', 40, 'rows', 10], 'Default Value', 'A short description of what the field is for.', false);



If you have any trouble editing the form as you need it then please post below or in the support board with the part you have edited (there's no need to post the whole code) and the URL to where you're trying to use it


- Ross

Image
Nick
Very Senior Member
*****

[Avatar]

Posts: 2,999
Status: Offline
Gender: Male
Location: vForums
Age: 27
Joined:  
Reputation: 62%  


pmwwwtwitterskypemsnyahooaimgtalkvForum
Re: Predefined Posting Template/Form (29th Nov 07 at 2:00am UTC)
Is this Cross Browser?

~Darkmage

Image
Ross
Administrator
*****

[Avatar]

Posts: 3,708
Status: Offline
Gender: Male
Age: 7 14
Joined:  

Additional Groups:
Support Team
***


Reputation: 45%  


pmwwwtwittergtalkvForum
Re: Predefined Posting Template/Form (29th Nov 07 at 9:57am UTC)
It should, at the very least, be working with Internet Explorer 6+ and Firefox 2+. I've not tested it in any other browsers like Opera or Safari.

Image
Nick
Very Senior Member
*****

[Avatar]

Posts: 2,999
Status: Offline
Gender: Male
Location: vForums
Age: 27
Joined:  
Reputation: 62%  


pmwwwtwitterskypemsnyahooaimgtalkvForum
Re: Predefined Posting Template/Form (30th Nov 07 at 1:07am UTC)
ok I only use Fire Fox, So then It should work, this would be good for my Advertising forum.

EDIT: I need help with this Code, I will Pm you what I need done with it.

Image
Nick
Very Senior Member
*****

[Avatar]

Posts: 2,999
Status: Offline
Gender: Male
Location: vForums
Age: 27
Joined:  
Reputation: 62%  


pmwwwtwitterskypemsnyahooaimgtalkvForum
Re: Predefined Posting Template/Form (2nd Dec 07 at 6:53am UTC)
This does not work. I put it in the boards footer I wanted it to be in, but it does not show up. I am giving you an example of what I mean:

Preview

~Darkmage

Image
Ross
Administrator
*****

[Avatar]

Posts: 3,708
Status: Offline
Gender: Male
Age: 7 14
Joined:  

Additional Groups:
Support Team
***


Reputation: 45%  


pmwwwtwittergtalkvForum
Re: Predefined Posting Template/Form (2nd Dec 07 at 7:47pm UTC)
The code works fine. You had just missed the </script> off of the end. I've added it back for you and it's now loading OK.

Image
Nick
Very Senior Member
*****

[Avatar]

Posts: 2,999
Status: Offline
Gender: Male
Location: vForums
Age: 27
Joined:  
Reputation: 62%  


pmwwwtwitterskypemsnyahooaimgtalkvForum
Re: Predefined Posting Template/Form (3rd Dec 07 at 12:55am UTC)
 
The code works fine. You had just missed the </script> off of the end. I've added it back for you and it's now loading OK.


{Embarassed} Whoops, lol. Sorry, I Guess I missed that when copying the code. {Tongue Out}

~Darkmage

Image
Nick
Very Senior Member
*****

[Avatar]

Posts: 2,999
Status: Offline
Gender: Male
Location: vForums
Age: 27
Joined:  
Reputation: 62%  


pmwwwtwitterskypemsnyahooaimgtalkvForum
Re: Predefined Posting Template/Form (9th Dec 07 at 12:17am UTC)
Hey the Code doesn't Separate its self when you post.

Example

~Darkmage

Image
Ross
Administrator
*****

[Avatar]

Posts: 3,708
Status: Offline
Gender: Male
Age: 7 14
Joined:  

Additional Groups:
Support Team
***


Reputation: 45%  


pmwwwtwittergtalkvForum
Re: Predefined Posting Template/Form (9th Dec 07 at 12:40am UTC)
OK, I've made a fix to the code in the first post. For some reason I had lost the backslashes {Embarassed}

Image
Nick
Very Senior Member
*****

[Avatar]

Posts: 2,999
Status: Offline
Gender: Male
Location: vForums
Age: 27
Joined:  
Reputation: 62%  


pmwwwtwitterskypemsnyahooaimgtalkvForum
Re: Predefined Posting Template/Form (9th Dec 07 at 12:46am UTC)
 
OK, I've made a fix to the code in the first post. For some reason I had lost the backslashes {Embarassed}


Ahh I see, and do I have to put the backslashes, or can you on my code?

Edit: Ahh I see the banner was to big in my sigy, I can resize it. What is the specific Height and length? I know for PB its 500x250.

Image
Ross
Administrator
*****

[Avatar]

Posts: 3,708
Status: Offline
Gender: Male
Age: 7 14
Joined:  

Additional Groups:
Support Team
***


Reputation: 45%  


pmwwwtwittergtalkvForum
Re: Predefined Posting Template/Form (9th Dec 07 at 12:58am UTC)
Ah yeah, I forgot you had a customised version:

Code:
 
  1. <script type="text/javascript">
  2. <!--
  3.  
  4. /* Predefined Posting Template/Form
  5.     Created by Ross of vForums
  6.     http://virtualforums.co.uk
  7.     Please do not repost outside of
  8.     vForums support without permission */
  9.  
  10. var _title = 'New Code Request';
  11.  
  12. var _description = 'Please ensure you have a read of the <a href="URL">Rules</a> before posting';
  13.  
  14. var _fields = new Array(); var _f = 0;
  15.     _fields[_f++] = new Array('input', 'Name of Website', ['size', 40, 'maxLength', 50], '', 'What is the name of your forum?', false);
  16.     _fields[_f++] = new Array('input', 'Username', ['size', 40, 'maxLength', 50], '', 'What is your Username on that forum?', false);
  17.     _fields[_f++] = new Array('input', 'Genre', ['size', 40, 'maxLength', 50], '', 'What Genre is your forum? IE: RPG, General, Coding ETC.', false);
  18.     _fields[_f++] = new Array('input', 'URL of Site/Forum', ['size', 40, 'maxLength', 250], '', 'Please give us your forums link.', false);
  19.     _fields[_f++] = new Array('textarea', 'Affiliate Code', ['cols', 40, 'rows', 3], '', 'Please give us your forums Affiliate Code.', false);
  20.     _fields[_f++] = new Array('input', 'Referral', ['size', 40, 'maxLength', 350], '', 'How did you find our forum? IE: Google, Advertisements, Affiliates ETC.', false);
  21.     _fields[_f++] = new Array('textarea', 'Description', ['cols', 40, 'rows', 4], '', 'Please give a Brief Description of your forum.', false);
  22.     _fields[_f++] = new Array('textarea', 'Additional Comments', ['cols', 40, 'rows', 4], '', 'Do you have any Comments Regarding our Forum, or your forum?', false);
  23.  
  24.  
  25. var _widths = ['100%', '20%', '40%', '40%'];
  26.  
  27. var _posting_form = {
  28.  
  29.     errors: new Array(),
  30.  
  31.     init: function() {
  32.         this.create_form();
  33.     },
  34.     
  35.     create_form: function() {
  36.         // Create new post layout
  37.         var _holder = document.createElement('table');
  38.         _holder.setAttribute('className', 'border');
  39.         _holder.setAttribute('class', 'border');
  40.         _holder.setAttribute('cellSpacing','1');
  41.         _holder.setAttribute('cellPadding', '4');
  42.         _holder.setAttribute('align', 'center');
  43.         _holder.setAttribute('width', _widths[0]);
  44.         _holder.setAttribute('id', 'post_form_holder');
  45.         _holder.appendChild(document.createElement('tbody'));
  46.         _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  47.         _holder.firstChild.lastChild.lastChild.className = 'title1';
  48.         _holder.firstChild.lastChild.lastChild.colSpan = '3';
  49.         _holder.firstChild.lastChild.lastChild.lastChild.size = '2';
  50.         _holder.firstChild.lastChild.lastChild.lastChild.appendChild(document.createTextNode(_title));
  51.         if(_description) {
  52.             _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  53.             _holder.firstChild.lastChild.lastChild.setAttribute('className', 'window1');
  54.             _holder.firstChild.lastChild.lastChild.setAttribute('class', 'window1');
  55.             _holder.firstChild.lastChild.lastChild.setAttribute('colSpan', '3');
  56.             _holder.firstChild.lastChild.lastChild.lastChild.setAttribute('size', '2');
  57.             _holder.firstChild.lastChild.lastChild.lastChild.innerHTML = _description;
  58.         }
  59.         
  60.         for(_f=0; _f<_fields.length; _f++) {
  61.             switch(_fields[_f][0]) {
  62.                 case 'textarea' :
  63.                     var _tmp = document.createElement('textarea');
  64.                 break;
  65.                 
  66.                 case 'select' :
  67.                     var _tmp = document.createElement('select');
  68.                     for(_o=0; _o<_fields[_f][3].length; _o++) {
  69.                         _tmp.options[_o] = new Option(_fields[_f][3][_o], _fields[_f][3][_o]);
  70.                     }
  71.                 break;
  72.                 
  73.                 default :
  74.                     var _tmp = document.createElement('input');
  75.                     _tmp.type = 'text';
  76.                     if("undefined" != typeof _fields[_f][3] && _fields[_f][3] != "")
  77.                         _tmp.setAttribute('value', _fields[_f][3]);
  78.                 break;
  79.             }
  80.             _tmp.setAttribute('id', _f);
  81.             if("undefined" != typeof _fields[_f][2] && _fields[_f][2].length > 0) {
  82.                 for(_a=0; _a<_fields[_f][2].length; _a++) {
  83.                     _tmp.setAttribute(_fields[_f][2][_a++], _fields[_f][2][_a]);
  84.                 }
  85.             }
  86.             var _class = 'window' + ((_f % 2 == 0)? '2' : '1');
  87.             var _row = document.createElement('tr');
  88.             _row.appendChild(document.createElement('td'));
  89.             _row.lastChild.setAttribute('class', _class);
  90.             _row.lastChild.setAttribute('className', _class);
  91.             _row.lastChild.setAttribute('vAlign', 'top');
  92.             _row.lastChild.setAttribute('width', _widths[1]);
  93.             _row.lastChild.appendChild(document.createElement('font'));
  94.             _row.lastChild.lastChild.setAttribute('size', '2');
  95.             _row.lastChild.lastChild.style.fontWeight = 'bold';
  96.             _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][1] + ':'));
  97.             _row.appendChild(document.createElement('td'));
  98.             _row.lastChild.setAttribute('class', _class);
  99.             _row.lastChild.setAttribute('className', _class);
  100.             _row.lastChild.setAttribute('width', _widths[2]);
  101.             _row.lastChild.appendChild(document.createElement('font'));
  102.             _row.lastChild.lastChild.setAttribute('size', '2');
  103.             _row.lastChild.lastChild.appendChild(_tmp);
  104.             _row.appendChild(document.createElement('td'));
  105.             _row.lastChild.setAttribute('class', _class);
  106.             _row.lastChild.setAttribute('className', _class);
  107.             _row.lastChild.setAttribute('vAlign', 'top');
  108.             _row.lastChild.setAttribute('width', _widths[3]);
  109.             _row.lastChild.appendChild(document.createElement('font'));
  110.             _row.lastChild.lastChild.size = '1';
  111.             _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][4]));
  112.             _holder.firstChild.appendChild(_row);
  113.         }
  114.         var _submit = document.createElement('tr');
  115.         _submit.appendChild(document.createElement('td'));
  116.         _submit.lastChild.setAttribute('class', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  117.         _submit.lastChild.setAttribute('className', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  118.         _submit.lastChild.setAttribute('align', 'center');
  119.         _submit.lastChild.setAttribute('colSpan', 3);
  120.         var _button = document.createElement('input');
  121.         _button.setAttribute('type', 'button');
  122.         _button.setAttribute('value', 'Post Message');
  123.         _button.onclick = function() { _posting_form.post_it(); };
  124.         _submit.lastChild.appendChild(_button);
  125.         _holder.firstChild.appendChild(_submit);
  126.         document.post_form.style.display = 'none';
  127.         document.post_form.parentNode.insertBefore(_holder,  document.post_form);
  128.     },
  129.     
  130.     post_it: function() {
  131.         // create message and attempt to post it
  132.         this.errors = new Array();
  133.         document.post_form.message.value = document.post_form.subject.value = '';
  134.         var _sub = document.getElementById('0').value;
  135.         _fields[0][5] = true;
  136.         document.post_form.subject.value    = _sub;
  137.         for(_f=0; _f<_fields.length; _f++) {
  138.             if(document.getElementById(_f)) {
  139.                 _value = document.getElementById(_f).value;
  140.                 if(!_value || _value.match(/^s*$/)) {
  141.                     if(_f > 0 && _fields[_f][5])
  142.                         this.show_error('You have left the ' + _fields[_f][1] + ' option empty. This is a required field and as such must contain a value.');
  143.                     else
  144.                         _value = '[i]None[/i]';
  145.                 }
  146.                 document.post_form.message.value += '[b]' + _fields[_f][1] + ':[/b] ' + _value + '\n\n';
  147.             }
  148.         }
  149.         if(this.errors.length == 0)
  150.             document.post_form.post.click();
  151.         else
  152.             this.show_error();
  153.     },
  154.     
  155.     show_error: function() {
  156.         if("undefined" != typeof arguments[0] && arguments[0]) {
  157.             this.errors.push(arguments[0]);
  158.         } else {
  159.             // Show Errors
  160.             if(document.getElementById('status_holder')) {
  161.                 document.getElementById('status_holder_title').innerHTML = "An Error Has Occured";
  162.                 document.getElementById('status_holder_message').innerHTML = this.errors.join("<br />");
  163.                 document.getElementById('status_holder').style.display = 'block';
  164.             }
  165.         }
  166.     }
  167. }
  168.  
  169.  
  170. if(document.post_form && location.href.match(/action\/post\/?$/) && vf_username != 'Guest') {
  171.     _posting_form.init();
  172. }
  173.  
  174. //-->
  175. </script>
 


For the banner, for now I'd rather images were kept to about 150px high. At least until I arrange some user preference for hiding signatures / large images {Smile}

Image
Nick
Very Senior Member
*****

[Avatar]

Posts: 2,999
Status: Offline
Gender: Male
Location: vForums
Age: 27
Joined:  
Reputation: 62%  


pmwwwtwitterskypemsnyahooaimgtalkvForum
Re: Predefined Posting Template/Form (9th Dec 07 at 1:02am UTC)
thanks, and I will keep that number in mind.

Image
Nick
Very Senior Member
*****

[Avatar]

Posts: 2,999
Status: Offline
Gender: Male
Location: vForums
Age: 27
Joined:  
Reputation: 62%  


pmwwwtwitterskypemsnyahooaimgtalkvForum
Re: Predefined Posting Template/Form (18th Dec 07 at 7:57pm UTC)
http://vfad.virtualforums.co.uk/board/Advertise/action/post/

The code does not work again {Unsure}

~Darkmage

Image
Ross
Administrator
*****

[Avatar]

Posts: 3,708
Status: Offline
Gender: Male
Age: 7 14
Joined:  

Additional Groups:
Support Team
***


Reputation: 45%  


pmwwwtwittergtalkvForum
Re: Predefined Posting Template/Form (18th Dec 07 at 8:40pm UTC)
Should be working now?

Image
Nick
Very Senior Member
*****

[Avatar]

Posts: 2,999
Status: Offline
Gender: Male
Location: vForums
Age: 27
Joined:  
Reputation: 62%  


pmwwwtwitterskypemsnyahooaimgtalkvForum
Re: Predefined Posting Template/Form (26th Dec 07 at 8:16am UTC)
I don't think I did this right, when I try to post, it wont show up. Here is the code:

Code:
 
  1. <script type="text/javascript">
  2. <!--
  3.  
  4. /* Predefined Posting Template/Form
  5.     Created by Ross of vForums
  6.     http://virtualforums.co.uk
  7.     Please do not repost outside of
  8.     vForums support without permission */
  9.  
  10. var _title = 'Character RP form';
  11.  
  12. var _description = '';
  13.  
  14. var _fields = new Array(); var _f = 0;
  15.     _fields[_f++] = new Array('input', 'Character name', ['size', 40, 'maxLength', 50], '', 'What is the name of your role-play character?', false);
  16.     _fields[_f++] = new Array('input', 'Age', ['size', 40, 'maxLength', 50], '', 'What is your role-play characters age?', false);
  17.     _fields[_f++] = new Array('input', 'Gender', ['size', 40, 'maxLength', 50], '', 'What is the gender of your RP character?', false);
  18.     _fields[_f++] = new Array('input', 'Species', ['size', 40, 'maxLength', 250], '', 'What is your characters Species?.', false);
  19.     _fields[_f++] = new Array('input', 'Good/Evil/Neutral', ['cols', 40, 'rows', 3], '', 'Please tell us if you are good, evil, or neutral.', false);
  20.     _fields[_f++] = new Array('textarea', 'Appearance', ['size', 40, 'maxLength', 350], '', 'Please give a description of your characters appearence.', false);
  21.     _fields[_f++] = new Array('textarea', 'Personality', ['cols', 40, 'rows', 4], '', 'What is your character personality like?.', false);
  22.     _fields[_f++] = new Array('textarea', 'History', ['size', 40, 'maxLength', 350], '', 'Please tell us you characters history.', false);
  23.     _fields[_f++] = new Array('textarea', 'Abilities', ['cols', 40, 'rows', 4], '', 'Please list your characters abilities', false);
  24.     _fields[_f++] = new Array('textarea', 'Weapon', ['cols', 40, 'rows', 4], '', 'What are your weapon(s)?', false);
  25.     _fields[_f++] = new Array('textarea', 'Hobbies', ['cols', 40, 'rows', 4], '', 'What are your characters hobbies?', false);
  26.     _fields[_f++] = new Array('textarea', 'Jobs', ['cols', 40, 'rows', 4], '', 'What kind of job does your character do? IE: Soldier, merchant, unemployed, etc.', false);
  27.     _fields[_f++] = new Array('textarea', 'Summons', ['cols', 40, 'rows', 4], '', 'What are your characters summons if any?' , false);
  28.  
  29.  
  30. var _widths = ['100%', '20%', '40%', '40%'];
  31.  
  32. var _posting_form = {
  33.  
  34.     errors: new Array(),
  35.  
  36.     init: function() {
  37.         this.create_form();
  38.     },
  39.     
  40.     create_form: function() {
  41.         // Create new post layout
  42.         var _holder = document.createElement('table');
  43.         _holder.setAttribute('className', 'border');
  44.         _holder.setAttribute('class', 'border');
  45.         _holder.setAttribute('cellSpacing','1');
  46.         _holder.setAttribute('cellPadding', '4');
  47.         _holder.setAttribute('align', 'center');
  48.         _holder.setAttribute('width', _widths[0]);
  49.         _holder.setAttribute('id', 'post_form_holder');
  50.         _holder.appendChild(document.createElement('tbody'));
  51.         _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  52.         _holder.firstChild.lastChild.lastChild.className = 'title1';
  53.         _holder.firstChild.lastChild.lastChild.colSpan = '3';
  54.         _holder.firstChild.lastChild.lastChild.lastChild.size = '2';
  55.         _holder.firstChild.lastChild.lastChild.lastChild.appendChild(document.createTextNode(_title));
  56.         if(_description) {
  57.             _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  58.             _holder.firstChild.lastChild.lastChild.setAttribute('className', 'window1');
  59.             _holder.firstChild.lastChild.lastChild.setAttribute('class', 'window1');
  60.             _holder.firstChild.lastChild.lastChild.setAttribute('colSpan', '3');
  61.             _holder.firstChild.lastChild.lastChild.lastChild.setAttribute('size', '2');
  62.             _holder.firstChild.lastChild.lastChild.lastChild.innerHTML = _description;
  63.         }
  64.         
  65.         for(_f=0; _f<_fields.length; _f++) {
  66.             switch(_fields[_f][0]) {
  67.                 case 'textarea' :
  68.                     var _tmp = document.createElement('textarea');
  69.                 break;
  70.                 
  71.                 case 'select' :
  72.                     var _tmp = document.createElement('select');
  73.                     for(_o=0; _o<_fields[_f][3].length; _o++) {
  74.                         _tmp.options[_o] = new Option(_fields[_f][3][_o], _fields[_f][3][_o]);
  75.                     }
  76.                 break;
  77.                 
  78.                 default :
  79.                     var _tmp = document.createElement('input');
  80.                     _tmp.type = 'text';
  81.                     if("undefined" != typeof _fields[_f][3] && _fields[_f][3] != "")
  82.                         _tmp.setAttribute('value', _fields[_f][3]);
  83.                 break;
  84.             }
  85.             _tmp.setAttribute('id', _f);
  86.             if("undefined" != typeof _fields[_f][2] && _fields[_f][2].length > 0) {
  87.                 for(_a=0; _a<_fields[_f][2].length; _a++) {
  88.                     _tmp.setAttribute(_fields[_f][2][_a++], _fields[_f][2][_a]);
  89.                 }
  90.             }
  91.             var _class = 'window' + ((_f % 2 == 0)? '2' : '1');
  92.             var _row = document.createElement('tr');
  93.             _row.appendChild(document.createElement('td'));
  94.             _row.lastChild.setAttribute('class', _class);
  95.             _row.lastChild.setAttribute('className', _class);
  96.             _row.lastChild.setAttribute('vAlign', 'top');
  97.             _row.lastChild.setAttribute('width', _widths[1]);
  98.             _row.lastChild.appendChild(document.createElement('font'));
  99.             _row.lastChild.lastChild.setAttribute('size', '2');
  100.             _row.lastChild.lastChild.style.fontWeight = 'bold';
  101.             _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][1] + ':'));
  102.             _row.appendChild(document.createElement('td'));
  103.             _row.lastChild.setAttribute('class', _class);
  104.             _row.lastChild.setAttribute('className', _class);
  105.             _row.lastChild.setAttribute('width', _widths[2]);
  106.             _row.lastChild.appendChild(document.createElement('font'));
  107.             _row.lastChild.lastChild.setAttribute('size', '2');
  108.             _row.lastChild.lastChild.appendChild(_tmp);
  109.             _row.appendChild(document.createElement('td'));
  110.             _row.lastChild.setAttribute('class', _class);
  111.             _row.lastChild.setAttribute('className', _class);
  112.             _row.lastChild.setAttribute('vAlign', 'top');
  113.             _row.lastChild.setAttribute('width', _widths[3]);
  114.             _row.lastChild.appendChild(document.createElement('font'));
  115.             _row.lastChild.lastChild.size = '1';
  116.             _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][4]));
  117.             _holder.firstChild.appendChild(_row);
  118.         }
  119.         var _submit = document.createElement('tr');
  120.         _submit.appendChild(document.createElement('td'));
  121.         _submit.lastChild.setAttribute('class', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  122.         _submit.lastChild.setAttribute('className', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  123.         _submit.lastChild.setAttribute('align', 'center');
  124.         _submit.lastChild.setAttribute('colSpan', 3);
  125.         var _button = document.createElement('input');
  126.         _button.setAttribute('type', 'button');
  127.         _button.setAttribute('value', 'Post Message');
  128.         _button.onclick = function() { _posting_form.post_it(); };
  129.         _submit.lastChild.appendChild(_button);
  130.         _holder.firstChild.appendChild(_submit);
  131.         document.post_form.style.display = 'none';
  132.         document.post_form.parentNode.insertBefore(_holder,  document.post_form);
  133.     },
  134.     
  135.     post_it: function() {
  136.         // create message and attempt to post it
  137.         this.errors = new Array();
  138.         document.post_form.message.value = document.post_form.subject.value = '';
  139.         var _sub = document.getElementById('0').value;
  140.         _fields[0][5] = true;
  141.         document.post_form.subject.value    = _sub;
  142.         for(_f=0; _f<_fields.length; _f++) {
  143.             if(document.getElementById(_f)) {
  144.                 _value = document.getElementById(_f).value;
  145.                 if(!_value || _value.match(/^s*$/)) {
  146.                     if(_f > 0 && _fields[_f][5])
  147.                         this.show_error('You have left the ' + _fields[_f][1] + ' option empty. This is a required field and as such must contain a value.');
  148.                     else
  149.                         _value = '[i]None[/i]';
  150.                 }
  151.                 document.post_form.message.value += '[b]' + _fields[_f][1] + ':[/b] ' + _value + '\n\n';
  152.             }
  153.         }
  154.         if(this.errors.length == 0)
  155.             document.post_form.post.click();
  156.         else
  157.             this.show_error();
  158.     },
  159.     
  160.     show_error: function() {
  161.         if("undefined" != typeof arguments[0] && arguments[0]) {
  162.             this.errors.push(arguments[0]);
  163.         } else {
  164.             // Show Errors
  165.             if(document.getElementById('status_holder')) {
  166.                 document.getElementById('status_holder_title').innerHTML = "An Error Has Occured";
  167.                 document.getElementById('status_holder_message').innerHTML = this.errors.join("<br />");
  168.                 document.getElementById('status_holder').style.display = 'block';
  169.             }
  170.         }
  171.     }
  172. }
  173.  
  174.  
  175.  
  176. if(document.post_form && location.href.match(/action\/post\/?$/) && vf_username != 'Guest') {
  177.     _posting_form.init();
  178. }
  179. //-->
  180. </script>
 


Thanks
~Darkmage

Image
 Printable View
Page: 1 2 3 4 5

All times are GMT+0 :: The current time is 5:41am
Page generated in 3.7908 seconds
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums