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 2 of 5)Page: 1 2 3 4 5
Topic Rating: *****
Printable View
Ross
Administrator
*****

[Avatar]

Posts: 3,709
Status: Offline
Gender: Male
Age: 8 11
Joined:  

Additional Groups:
Support Team
***


Reputation: 45%  


pmwwwtwittergtalkvForum
Re: Predefined Posting Template/Form (27th Dec 07 at 12:53am UTC)
I've modified the code in your post if you want to recopy from there. You were missing an apostrophe.

Image
Nick
Very Senior Member
*****

[Avatar]

Posts: 3,012
Status: Offline
Gender: Male
Location: vForums
Age: 34
Joined:  
Reputation: 62%  


pmwww
Re: Predefined Posting Template/Form (27th Dec 07 at 12:59am UTC)
Ok thanks lol ^_^
gray929
Junior Member
**

[Avatar]

Posts: 129
Status: Offline
Age: 32
Joined:  
Reputation: 2%  


pm
Re: Predefined Posting Template/Form (6th Jan 08 at 8:30pm UTC)
Excellent code. Just what I needed.

Need a Sig?
gray929
Junior Member
**

[Avatar]

Posts: 129
Status: Offline
Age: 32
Joined:  
Reputation: 2%  


pm
Re: Predefined Posting Template/Form (10th Jan 08 at 2:24am UTC)
Question about the dropdown box. When I added this:

Code:
 
  1. _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);
 


The options I wanted in the dropdown all went into the text field. All I did was change the names above. Am I missing a step?

Need a Sig?
Marc
vChat Developer
*****
I <3 Rossy

Posts: 3,388
Status: Offline
Gender: Male
Location: Ontario, Canada
Age: 32
Joined:  

Additional Groups:
Coding Team
***


Reputation: 40%  


pmwww
Re: Predefined Posting Template/Form (10th Jan 08 at 2:57am UTC)
Can you post a link, please? {Smile}

rroll.to— Shorten a link, rickroll your friends.
gray929
Junior Member
**

[Avatar]

Posts: 129
Status: Offline
Age: 32
Joined:  
Reputation: 2%  


pm
Re: Predefined Posting Template/Form (10th Jan 08 at 11:18pm UTC)
 
Can you post a link, please? {Smile}


Link: http://www.gaming.virtualforums.co.uk

Screenshot:

Image

Need a Sig?
Michael
Moderator
*****

[Avatar]
Recoding the future

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

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Predefined Posting Template/Form (10th Jan 08 at 11:28pm UTC)
could you PM me your editted version of the code so that I can test it on a test board please? {Smile}
gray929
Junior Member
**

[Avatar]

Posts: 129
Status: Offline
Age: 32
Joined:  
Reputation: 2%  


pm
Re: Predefined Posting Template/Form (10th Jan 08 at 11:30pm UTC)
 
could you PM me your editted version of the code so that I can test it on a test board please? {Smile}


No. It's too long.

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', 'Platform', ['size', 40, 'maxLength', 50], '', 'Xbox 360, Playstation 3, Nintendo Wii', false);
  16.     _fields[_f++] = new Array('Xbox Live', 'Field Name, ie. "Gender" or "Type"', [], ['All Pages', 'Main Page', 'Mini-Profile', 'Info Center', 'Private Messaging', 'Profile', 'Posting', 'Thread Listing', 'Welcome Table', 'Other'], 'What is the issue you are encountering?', true);
  17.     _fields[_f++] = new Array('input', 'Genre', ['size', 40, 'maxLength', 50], '', 'What Genre is your forum? IE: RPG, General, Coding ETC.', false);
  18.  
  19. var _widths = ['100%', '20%', '40%', '40%'];
  20.  
  21. var _posting_form = {
  22.  
  23.     errors: new Array(),
  24.  
  25.     init: function() {
  26.         this.create_form();
  27.     },
  28.     
  29.     create_form: function() {
  30.         // Create new post layout
  31.         var _holder = document.createElement('table');
  32.         _holder.setAttribute('className', 'border');
  33.         _holder.setAttribute('class', 'border');
  34.         _holder.setAttribute('cellSpacing','1');
  35.         _holder.setAttribute('cellPadding', '4');
  36.         _holder.setAttribute('align', 'center');
  37.         _holder.setAttribute('width', _widths[0]);
  38.         _holder.setAttribute('id', 'post_form_holder');
  39.         _holder.appendChild(document.createElement('tbody'));
  40.         _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  41.         _holder.firstChild.lastChild.lastChild.className = 'title1';
  42.         _holder.firstChild.lastChild.lastChild.colSpan = '3';
  43.         _holder.firstChild.lastChild.lastChild.lastChild.size = '2';
  44.         _holder.firstChild.lastChild.lastChild.lastChild.appendChild(document.createTextNode(_title));
  45.         if(_description) {
  46.             _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  47.             _holder.firstChild.lastChild.lastChild.setAttribute('className', 'window1');
  48.             _holder.firstChild.lastChild.lastChild.setAttribute('class', 'window1');
  49.             _holder.firstChild.lastChild.lastChild.setAttribute('colSpan', '3');
  50.             _holder.firstChild.lastChild.lastChild.lastChild.setAttribute('size', '2');
  51.             _holder.firstChild.lastChild.lastChild.lastChild.innerHTML = _description;
  52.         }
  53.         
  54.         for(_f=0; _f<_fields.length; _f++) {
  55.             switch(_fields[_f][0]) {
  56.                 case 'textarea' :
  57.                     var _tmp = document.createElement('textarea');
  58.                 break;
  59.                 
  60.                 case 'select' :
  61.                     var _tmp = document.createElement('select');
  62.                     for(_o=0; _o<_fields[_f][3].length; _o++) {
  63.                         _tmp.options[_o] = new Option(_fields[_f][3][_o], _fields[_f][3][_o]);
  64.                     }
  65.                 break;
  66.                 
  67.                 default :
  68.                     var _tmp = document.createElement('input');
  69.                     _tmp.type = 'text';
  70.                     if("undefined" != typeof _fields[_f][3] && _fields[_f][3] != "")
  71.                         _tmp.setAttribute('value', _fields[_f][3]);
  72.                 break;
  73.             }
  74.             _tmp.setAttribute('id', _f);
  75.             if("undefined" != typeof _fields[_f][2] && _fields[_f][2].length > 0) {
  76.                 for(_a=0; _a<_fields[_f][2].length; _a++) {
  77.                     _tmp.setAttribute(_fields[_f][2][_a++], _fields[_f][2][_a]);
  78.                 }
  79.             }
  80.             var _class = 'window' + ((_f % 2 == 0)? '2' : '1');
  81.             var _row = document.createElement('tr');
  82.             _row.appendChild(document.createElement('td'));
  83.             _row.lastChild.setAttribute('class', _class);
  84.             _row.lastChild.setAttribute('className', _class);
  85.             _row.lastChild.setAttribute('vAlign', 'top');
  86.             _row.lastChild.setAttribute('width', _widths[1]);
  87.             _row.lastChild.appendChild(document.createElement('font'));
  88.             _row.lastChild.lastChild.setAttribute('size', '2');
  89.             _row.lastChild.lastChild.style.fontWeight = 'bold';
  90.             _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][1] + ':'));
  91.             _row.appendChild(document.createElement('td'));
  92.             _row.lastChild.setAttribute('class', _class);
  93.             _row.lastChild.setAttribute('className', _class);
  94.             _row.lastChild.setAttribute('width', _widths[2]);
  95.             _row.lastChild.appendChild(document.createElement('font'));
  96.             _row.lastChild.lastChild.setAttribute('size', '2');
  97.             _row.lastChild.lastChild.appendChild(_tmp);
  98.             _row.appendChild(document.createElement('td'));
  99.             _row.lastChild.setAttribute('class', _class);
  100.             _row.lastChild.setAttribute('className', _class);
  101.             _row.lastChild.setAttribute('vAlign', 'top');
  102.             _row.lastChild.setAttribute('width', _widths[3]);
  103.             _row.lastChild.appendChild(document.createElement('font'));
  104.             _row.lastChild.lastChild.size = '1';
  105.             _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][4]));
  106.             _holder.firstChild.appendChild(_row);
  107.         }
  108.         var _submit = document.createElement('tr');
  109.         _submit.appendChild(document.createElement('td'));
  110.         _submit.lastChild.setAttribute('class', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  111.         _submit.lastChild.setAttribute('className', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  112.         _submit.lastChild.setAttribute('align', 'center');
  113.         _submit.lastChild.setAttribute('colSpan', 3);
  114.         var _button = document.createElement('input');
  115.         _button.setAttribute('type', 'button');
  116.         _button.setAttribute('value', 'Post Message');
  117.         _button.onclick = function() { _posting_form.post_it(); };
  118.         _submit.lastChild.appendChild(_button);
  119.         _holder.firstChild.appendChild(_submit);
  120.         document.post_form.style.display = 'none';
  121.         document.post_form.parentNode.insertBefore(_holder,  document.post_form);
  122.     },
  123.     
  124.     post_it: function() {
  125.         // create message and attempt to post it
  126.         this.errors = new Array();
  127.         document.post_form.message.value = document.post_form.subject.value = '';
  128.         var _sub = document.getElementById('0').value;
  129.         _fields[0][5] = true;
  130.         document.post_form.subject.value    = _sub;
  131.         for(_f=0; _f<_fields.length; _f++) {
  132.             if(document.getElementById(_f)) {
  133.                 _value = document.getElementById(_f).value;
  134.                 if(!_value || _value.match(/^s*$/)) {
  135.                     if(_f > 0 && _fields[_f][5])
  136.                         this.show_error('You have left the ' + _fields[_f][1] + ' option empty. This is a required field and as such must contain a value.');
  137.                     else
  138.                         _value = '[i]None[/i]';
  139.                 }
  140.                 document.post_form.message.value += '[b]' + _fields[_f][1] + ':[/b] ' + _value + '\n\n';
  141.             }
  142.         }
  143.         if(this.errors.length == 0)
  144.             document.post_form.post.click();
  145.         else
  146.             this.show_error();
  147.     },
  148.     
  149.     show_error: function() {
  150.         if("undefined" != typeof arguments[0] && arguments[0]) {
  151.             this.errors.push(arguments[0]);
  152.         } else {
  153.             // Show Errors
  154.             if(document.getElementById('status_holder')) {
  155.                 document.getElementById('status_holder_title').innerHTML = "An Error Has Occured";
  156.                 document.getElementById('status_holder_message').innerHTML = this.errors.join("<br />");
  157.                 document.getElementById('status_holder').style.display = 'block';
  158.             }
  159.         }
  160.     }
  161. }
  162.  
  163.  
  164. if(document.post_form && location.href.match(/action\/post\/?$/) && vf_username != 'Guest') {
  165.     _posting_form.init();
  166. }
  167.  
  168. //-->
  169. </script>
 

Need a Sig?
Michael
Moderator
*****

[Avatar]
Recoding the future

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

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Predefined Posting Template/Form (10th Jan 08 at 11:34pm UTC)
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', 'Platform', ['size', 40, 'maxLength', 50], '', 'Xbox 360, Playstation 3, Nintendo Wii', false);
  16.     _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'], 'What is the issue you are encountering?', true);
  17.     _fields[_f++] = new Array('input', 'Genre', ['size', 40, 'maxLength', 50], '', 'What Genre is your forum? IE: RPG, General, Coding ETC.', false);
  18.  
  19. var _widths = ['100%', '20%', '40%', '40%'];
  20.  
  21. var _posting_form = {
  22.  
  23.     errors: new Array(),
  24.  
  25.     init: function() {
  26.         this.create_form();
  27.     },
  28.     
  29.     create_form: function() {
  30.         // Create new post layout
  31.         var _holder = document.createElement('table');
  32.         _holder.setAttribute('className', 'border');
  33.         _holder.setAttribute('class', 'border');
  34.         _holder.setAttribute('cellSpacing','1');
  35.         _holder.setAttribute('cellPadding', '4');
  36.         _holder.setAttribute('align', 'center');
  37.         _holder.setAttribute('width', _widths[0]);
  38.         _holder.setAttribute('id', 'post_form_holder');
  39.         _holder.appendChild(document.createElement('tbody'));
  40.         _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  41.         _holder.firstChild.lastChild.lastChild.className = 'title1';
  42.         _holder.firstChild.lastChild.lastChild.colSpan = '3';
  43.         _holder.firstChild.lastChild.lastChild.lastChild.size = '2';
  44.         _holder.firstChild.lastChild.lastChild.lastChild.appendChild(document.createTextNode(_title));
  45.         if(_description) {
  46.             _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  47.             _holder.firstChild.lastChild.lastChild.setAttribute('className', 'window1');
  48.             _holder.firstChild.lastChild.lastChild.setAttribute('class', 'window1');
  49.             _holder.firstChild.lastChild.lastChild.setAttribute('colSpan', '3');
  50.             _holder.firstChild.lastChild.lastChild.lastChild.setAttribute('size', '2');
  51.             _holder.firstChild.lastChild.lastChild.lastChild.innerHTML = _description;
  52.         }
  53.         
  54.         for(_f=0; _f<_fields.length; _f++) {
  55.             switch(_fields[_f][0]) {
  56.                 case 'textarea' :
  57.                     var _tmp = document.createElement('textarea');
  58.                 break;
  59.                 
  60.                 case 'select' :
  61.                     var _tmp = document.createElement('select');
  62.                     for(_o=0; _o<_fields[_f][3].length; _o++) {
  63.                         _tmp.options[_o] = new Option(_fields[_f][3][_o], _fields[_f][3][_o]);
  64.                     }
  65.                 break;
  66.                 
  67.                 default :
  68.                     var _tmp = document.createElement('input');
  69.                     _tmp.type = 'text';
  70.                     if("undefined" != typeof _fields[_f][3] && _fields[_f][3] != "")
  71.                         _tmp.setAttribute('value', _fields[_f][3]);
  72.                 break;
  73.             }
  74.             _tmp.setAttribute('id', _f);
  75.             if("undefined" != typeof _fields[_f][2] && _fields[_f][2].length > 0) {
  76.                 for(_a=0; _a<_fields[_f][2].length; _a++) {
  77.                     _tmp.setAttribute(_fields[_f][2][_a++], _fields[_f][2][_a]);
  78.                 }
  79.             }
  80.             var _class = 'window' + ((_f % 2 == 0)? '2' : '1');
  81.             var _row = document.createElement('tr');
  82.             _row.appendChild(document.createElement('td'));
  83.             _row.lastChild.setAttribute('class', _class);
  84.             _row.lastChild.setAttribute('className', _class);
  85.             _row.lastChild.setAttribute('vAlign', 'top');
  86.             _row.lastChild.setAttribute('width', _widths[1]);
  87.             _row.lastChild.appendChild(document.createElement('font'));
  88.             _row.lastChild.lastChild.setAttribute('size', '2');
  89.             _row.lastChild.lastChild.style.fontWeight = 'bold';
  90.             _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][1] + ':'));
  91.             _row.appendChild(document.createElement('td'));
  92.             _row.lastChild.setAttribute('class', _class);
  93.             _row.lastChild.setAttribute('className', _class);
  94.             _row.lastChild.setAttribute('width', _widths[2]);
  95.             _row.lastChild.appendChild(document.createElement('font'));
  96.             _row.lastChild.lastChild.setAttribute('size', '2');
  97.             _row.lastChild.lastChild.appendChild(_tmp);
  98.             _row.appendChild(document.createElement('td'));
  99.             _row.lastChild.setAttribute('class', _class);
  100.             _row.lastChild.setAttribute('className', _class);
  101.             _row.lastChild.setAttribute('vAlign', 'top');
  102.             _row.lastChild.setAttribute('width', _widths[3]);
  103.             _row.lastChild.appendChild(document.createElement('font'));
  104.             _row.lastChild.lastChild.size = '1';
  105.             _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][4]));
  106.             _holder.firstChild.appendChild(_row);
  107.         }
  108.         var _submit = document.createElement('tr');
  109.         _submit.appendChild(document.createElement('td'));
  110.         _submit.lastChild.setAttribute('class', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  111.         _submit.lastChild.setAttribute('className', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  112.         _submit.lastChild.setAttribute('align', 'center');
  113.         _submit.lastChild.setAttribute('colSpan', 3);
  114.         var _button = document.createElement('input');
  115.         _button.setAttribute('type', 'button');
  116.         _button.setAttribute('value', 'Post Message');
  117.         _button.onclick = function() { _posting_form.post_it(); };
  118.         _submit.lastChild.appendChild(_button);
  119.         _holder.firstChild.appendChild(_submit);
  120.         document.post_form.style.display = 'none';
  121.         document.post_form.parentNode.insertBefore(_holder,  document.post_form);
  122.     },
  123.     
  124.     post_it: function() {
  125.         // create message and attempt to post it
  126.         this.errors = new Array();
  127.         document.post_form.message.value = document.post_form.subject.value = '';
  128.         var _sub = document.getElementById('0').value;
  129.         _fields[0][5] = true;
  130.         document.post_form.subject.value    = _sub;
  131.         for(_f=0; _f<_fields.length; _f++) {
  132.             if(document.getElementById(_f)) {
  133.                 _value = document.getElementById(_f).value;
  134.                 if(!_value || _value.match(/^s*$/)) {
  135.                     if(_f > 0 && _fields[_f][5])
  136.                         this.show_error('You have left the ' + _fields[_f][1] + ' option empty. This is a required field and as such must contain a value.');
  137.                     else
  138.                         _value = '[i]None[/i]';
  139.                 }
  140.                 document.post_form.message.value += '[b]' + _fields[_f][1] + ':[/b] ' + _value + '\n\n';
  141.             }
  142.         }
  143.         if(this.errors.length == 0)
  144.             document.post_form.post.click();
  145.         else
  146.             this.show_error();
  147.     },
  148.     
  149.     show_error: function() {
  150.         if("undefined" != typeof arguments[0] && arguments[0]) {
  151.             this.errors.push(arguments[0]);
  152.         } else {
  153.             // Show Errors
  154.             if(document.getElementById('status_holder')) {
  155.                 document.getElementById('status_holder_title').innerHTML = "An Error Has Occured";
  156.                 document.getElementById('status_holder_message').innerHTML = this.errors.join("<br />");
  157.                 document.getElementById('status_holder').style.display = 'block';
  158.             }
  159.         }
  160.     }
  161. }
  162.  
  163.  
  164. if(document.post_form && location.href.match(/action\/post\/?$/) && vf_username != 'Guest') {
  165.     _posting_form.init();
  166. }
  167.  
  168. //-->
  169. </script>
 


Try that! {Smile}

Works for me on a test board! {Grin}
gray929
Junior Member
**

[Avatar]

Posts: 129
Status: Offline
Age: 32
Joined:  
Reputation: 2%  


pm
Re: Predefined Posting Template/Form (10th Jan 08 at 11:40pm UTC)
Works now. Thanks Wrighty. What did you do? {Cool}

Need a Sig?
Michael
Moderator
*****

[Avatar]
Recoding the future

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

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Predefined Posting Template/Form (10th Jan 08 at 11:41pm UTC)
you had the field type set to: "Xbox Live" Strange... so just changed it to 'select'! {Smile}
gray929
Junior Member
**

[Avatar]

Posts: 129
Status: Offline
Age: 32
Joined:  
Reputation: 2%  


pm
Re: Predefined Posting Template/Form (11th Jan 08 at 12:11am UTC)
 
you had the field type set to: "Xbox Live" Strange... so just changed it to 'select'! {Smile}


Must have gotten caught up with all the variables.

Is there a way to make it so if a user selects an option, for instance "Other" a text field will show up?

Need a Sig?
Michael
Moderator
*****

[Avatar]
Recoding the future

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

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Predefined Posting Template/Form (11th Jan 08 at 12:50am UTC)
I am not prepared to go and modify Ross' code for that! {Sad}

Couldn't you just have the text field showing and have a description saying: "only fill if 'other' is selected"?
gray929
Junior Member
**

[Avatar]

Posts: 129
Status: Offline
Age: 32
Joined:  
Reputation: 2%  


pm
Re: Predefined Posting Template/Form (11th Jan 08 at 2:19am UTC)
 
I am not prepared to go and modify Ross' code for that! {Sad}

Couldn't you just have the text field showing and have a description saying: "only fill if 'other' is selected"?


I wasn't asking you to, just wondering {Tongue Out} I guess I could do that. Thanks.

Need a Sig?
dog199200
Guest
Re: Predefined Posting Template/Form (23rd Jan 08 at 1:43am UTC)
Hey Ross just to let you know, you need to fix the original code in this post. It dont work...at first i thought that editing it made it not work, but then i tired the code with out editing and it still don't work...
 Printable View
Page: 1 2 3 4 5

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