vForums Support Banner


Visit Base Classics - Gaming Chairs

 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Code Requests & Support :: [F] Posting Template Not Working - View Topic
Topic Rating: *****
Printable View
This topic was locked 8th Mar 08 at 10:51pm by Michael
dog199200
Guest
[F] Posting Template Not Working (8th Mar 08 at 10:31pm UTC)
http://phoenixemerald.virtualforums.co.uk

It was working then all of a sudden it quick working, why?

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 Profile';
  11.  
  12. var _description = 'Fill this out and post it to make your characters profile.';
  13.  
  14. var _fields = new Array(); var _f = 0;
  15.     _fields[_f++] = new Array('input', 'Character Full Name', ['size', 40, 'maxLength', 50], '', 'Your characters full name, first and last.', true);
  16.     _fields[_f++] = new Array('input', 'Character NickName', ['size', 40, 'maxLength', 50], '', 'Character Nickname (If Doesnt Got One Just Put * )', true);
  17.     _fields[_f++] = new Array('input', 'Character Age', ['size', 40, 'maxLength', 50], '', 'Put Your characters age here.', true);
  18.     _fields[_f++] = new Array('input', 'Character Height', ['size', 40, 'maxLength', 50], '', 'Whats the height of your character?', true);
  19.     _fields[_f++] = new Array('select', 'Character Gender', false, ['Male', 'Female'], 'Whats your characters Gender?', true);
  20.     _fields[_f++] = new Array('select', 'Character Time', false, ['Japan', 'Feudal Japan'], 'What time is your character from? *Keep in mind that this sets where you can RP*', true);
  21.     _fields[_f++] = new Array('input', 'Character Eye Color', ['size', 40, 'maxLength', 50], '', 'Whats your characters eye color?', true);
  22.     _fields[_f++] = new Array('input', 'Character Hair Color', ['size', 40, 'maxLength', 50], '', 'Whats your characters hair color?', true);
  23.     _fields[_f++] = new Array('input', 'Character Skin Color', ['size', 40, 'maxLength', 50], '', 'Whats your characters skin color?', true);
  24.     _fields[_f++] = new Array('input', 'Character Race', ['size', 40, 'maxLength', 200], '', 'Whats your characters Class?', true);
  25.     _fields[_f++] = new Array('select', 'Character Ailment', false, ['Good', 'Neutral', 'Evil'], 'Whats your characters Aliment?', true);
  26.     _fields[_f++] = new Array('input', 'Character Weapon', ['size', 40, 'maxLength', 50], '', 'Whats your characters Weapon?', true);
  27.     _fields[_f++] = new Array('textarea', 'Character Weapon Description', ['cols', 40, 'rows', 10], false, 'Whats the description of your characters weapon?', true);
  28.     _fields[_f++] = new Array('textarea', 'Character Skillz', ['cols', 40, 'rows', 10], false, 'Whats your characters skillz?', true);
  29.     _fields[_f++] = new Array('input', 'Character Description', ['size', 40, 'maxLength', 10], false, 'Whats your character looks like. (Pics allowed)', true);
  30.     _fields[_f++] = new Array('textarea', 'Character Bio', ['cols', 40, 'rows', 10], false, 'Whats the story behind your character?', true);
  31.     _fields[_f++] = new Array('input', 'Password', ['size', 40, 'maxLength', 50], '', 'If you read the rules youd know what this means. (Most be filled in with the right password or your profile will not be accepted.', true);
  32.  
  33. var _widths = ['100%', '20%', '40%', '40%'];
  34.  
  35. var _posting_form = {
  36.  
  37.     errors: new Array(),
  38.  
  39.     init: function() {
  40.         this.create_form();
  41.     },
  42.     
  43.     create_form: function() {
  44.         // Create new post layout
  45.         var _holder = document.createElement('table');
  46.         _holder.setAttribute('className', 'border');
  47.         _holder.setAttribute('class', 'border');
  48.         _holder.setAttribute('cellSpacing','1');
  49.         _holder.setAttribute('cellPadding', '4');
  50.         _holder.setAttribute('align', 'center');
  51.         _holder.setAttribute('width', _widths[0]);
  52.         _holder.setAttribute('id', 'post_form_holder');
  53.         _holder.appendChild(document.createElement('tbody'));
  54.         _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  55.         _holder.firstChild.lastChild.lastChild.className = 'title1';
  56.         _holder.firstChild.lastChild.lastChild.colSpan = '3';
  57.         _holder.firstChild.lastChild.lastChild.lastChild.size = '2';
  58.         _holder.firstChild.lastChild.lastChild.lastChild.appendChild(document.createTextNode(_title));
  59.         if(_description) {
  60.             _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  61.             _holder.firstChild.lastChild.lastChild.setAttribute('className', 'window1');
  62.             _holder.firstChild.lastChild.lastChild.setAttribute('class', 'window1');
  63.             _holder.firstChild.lastChild.lastChild.setAttribute('colSpan', '3');
  64.             _holder.firstChild.lastChild.lastChild.lastChild.setAttribute('size', '2');
  65.             _holder.firstChild.lastChild.lastChild.lastChild.innerHTML = _description;
  66.         }
  67.         
  68.         for(_f=0; _f<_fields.length; _f++) {
  69.             switch(_fields[_f][0]) {
  70.                 case 'textarea' :
  71.                     var _tmp = document.createElement('textarea');
  72.                 break;
  73.                 
  74.                 case 'select' :
  75.                     var _tmp = document.createElement('select');
  76.                     for(_o=0; _o<_fields[_f][3].length; _o++) {
  77.                         _tmp.options[_o] = new Option(_fields[_f][3][_o], _fields[_f][3][_o]);
  78.                     }
  79.                 break;
  80.                 
  81.                 default :
  82.                     var _tmp = document.createElement('input');
  83.                     _tmp.type = 'text';
  84.                     if("undefined" != typeof _fields[_f][3] && _fields[_f][3] != "")
  85.                         _tmp.setAttribute('value', _fields[_f][3]);
  86.                 break;
  87.             }
  88.             _tmp.setAttribute('id', _f);
  89.             if("undefined" != typeof _fields[_f][2] && _fields[_f][2].length > 0) {
  90.                 for(_a=0; _a<_fields[_f][2].length; _a++) {
  91.                     _tmp.setAttribute(_fields[_f][2][_a++], _fields[_f][2][_a]);
  92.                 }
  93.             }
  94.             var _class = 'window' + ((_f % 2 == 0)? '2' : '1');
  95.             var _row = document.createElement('tr');
  96.             _row.appendChild(document.createElement('td'));
  97.             _row.lastChild.setAttribute('class', _class);
  98.             _row.lastChild.setAttribute('className', _class);
  99.             _row.lastChild.setAttribute('vAlign', 'top');
  100.             _row.lastChild.setAttribute('width', _widths[1]);
  101.             _row.lastChild.appendChild(document.createElement('font'));
  102.             _row.lastChild.lastChild.setAttribute('size', '2');
  103.             _row.lastChild.lastChild.style.fontWeight = 'bold';
  104.             _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][1] + ':'));
  105.             _row.appendChild(document.createElement('td'));
  106.             _row.lastChild.setAttribute('class', _class);
  107.             _row.lastChild.setAttribute('className', _class);
  108.             _row.lastChild.setAttribute('width', _widths[2]);
  109.             _row.lastChild.appendChild(document.createElement('font'));
  110.             _row.lastChild.lastChild.setAttribute('size', '2');
  111.             _row.lastChild.lastChild.appendChild(_tmp);
  112.             _row.appendChild(document.createElement('td'));
  113.             _row.lastChild.setAttribute('class', _class);
  114.             _row.lastChild.setAttribute('className', _class);
  115.             _row.lastChild.setAttribute('vAlign', 'top');
  116.             _row.lastChild.setAttribute('width', _widths[3]);
  117.             _row.lastChild.appendChild(document.createElement('font'));
  118.             _row.lastChild.lastChild.size = '1';
  119.             _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][4]));
  120.             _holder.firstChild.appendChild(_row);
  121.         }
  122.         var _submit = document.createElement('tr');
  123.         _submit.appendChild(document.createElement('td'));
  124.         _submit.lastChild.setAttribute('class', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  125.         _submit.lastChild.setAttribute('className', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  126.         _submit.lastChild.setAttribute('align', 'center');
  127.         _submit.lastChild.setAttribute('colSpan', 3);
  128.         var _button = document.createElement('input');
  129.         _button.setAttribute('type', 'button');
  130.         _button.setAttribute('value', 'Post Message');
  131.         _button.onclick = function() { _posting_form.post_it(); };
  132.         _submit.lastChild.appendChild(_button);
  133.         _holder.firstChild.appendChild(_submit);
  134.         document.post_form.style.display = 'none';
  135.         document.post_form.parentNode.insertBefore(_holder,  document.post_form);
  136.     },
  137.     
  138.     post_it: function() {
  139.         // create message and attempt to post it
  140.         this.errors = new Array();
  141.         document.post_form.message.value = document.post_form.subject.value = '';
  142.         var _sub = document.getElementById('0').value;
  143.         _fields[0][5] = true;
  144.         document.post_form.subject.value    = _sub;
  145.         for(_f=0; _f<_fields.length; _f++) {
  146.             if(document.getElementById(_f)) {
  147.                 _value = document.getElementById(_f).value;
  148.                 if(!_value || _value.match(/^s*$/)) {
  149.                     if(_f > 0 && _fields[_f][5])
  150.                         this.show_error('You have left the ' + _fields[_f][1] + ' option empty. This is a required field and as such must contain a value.');
  151.                     else
  152.                         _value = '[i]None[/i]';
  153.                 }
  154.                 document.post_form.message.value += '[b]' + _fields[_f][1] + ':[/b] ' + _value + 'nn';
  155.             }
  156.         }
  157.         if(this.errors.length == 0)
  158.             document.post_form.post.click();
  159.         else
  160.             this.show_error();
  161.     },
  162.     
  163.     show_error: function() {
  164.         if("undefined" != typeof arguments[0] && arguments[0]) {
  165.             this.errors.push(arguments[0]);
  166.         } else {
  167.             // Show Errors
  168.             if(document.getElementById('status_holder')) {
  169.                 document.getElementById('status_holder_title').innerHTML = "An Error Has Occured";
  170.                 document.getElementById('status_holder_message').innerHTML = this.errors.join("<br />");
  171.                 document.getElementById('status_holder').style.display = 'block';
  172.             }
  173.         }
  174.     }
  175. }
  176.  
  177.  
  178. if(document.post_form && location.href.match(/action\/post\/?$/) && vf_username != 'Guest') {
  179.     _posting_form.init();
  180. }
  181.  
  182. //-->
  183. </script>
 
Michael
Moderator
*****

[Avatar]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Posting Template Not Working (8th Mar 08 at 10:34pm UTC)
Please can you tell us which board you're using it in.
dog199200
Guest
Re: Posting Template Not Working (8th Mar 08 at 10:35pm UTC)
the Character Profile board, also i'm going to try the code on anther board and see if it works.
Michael
Moderator
*****

[Avatar]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Posting Template Not Working (8th Mar 08 at 10:37pm UTC)
http://wrighty.virtualforums.co.uk/board/general/action/post/

It works fine for me on my test board.
Ross
Administrator
*****

[Avatar]

Posts: 3,709
Status: Offline
Gender: Male
Age: 9 14
Joined:  

Additional Groups:
Support Team
***


Reputation: 45%  


pmwwwtwittergtalkvForum
Re: Posting Template Not Working (8th Mar 08 at 10:40pm UTC)
Line breaks in your hidden vars field (from your profile) was breaking the global vars. I've fixed that and the form shows up OK now {Smile}

Image
dog199200
Guest
Re: Posting Template Not Working (8th Mar 08 at 10:51pm UTC)
ya after i tested it on another forum and it worked then i figured that it was a bug somewhere
 Printable View

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