vForums Support Banner



 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Code Requests & Support :: [F] help with this code please - View Topic
Topic Rating: *****
Printable View
CåñåÐå™
Full Member
***

[Avatar]

Posts: 427
Status: Offline
Gender: Male
Location: Toronto Ontario
Joined:  
Reputation: 7%  


pmwww
[F] help with this code please (23rd Feb 08 at 11:25am UTC)
Right now this code is in my Affiliates board footer but its not working {Confused}
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="http://capecoral.vforums.co.uk/board/general/topic/3/action/view_topic/page/1/rules/">Rules</a> before posting. If you break the rules, your thread will be locked and moved to a hidden board for dead codes. You are free to repost your code if you don't break the rules again. Repeatedly breaking the rules will result in a warning.';
  13.  
  14. var _fields = new Array(); var _f = 0;
  15. _fields[_f++] = new Array('input', '*Code Type', ['size', 40, 'maxLength', 50], '', 'Type of Code/Code Name', true);
  16.  
  17. _fields[_f++] = new Array('input', 'Forum Link', ['size', 40, 'maxLength', 50], '', 'Link to Your Forum', false);
  18. _fields[_f++] = new Array('input', 'Browser', ['size', 40, 'maxLength', 50], '', 'Browser that you use.', false);
  19.  
  20. _fields[_f++] = new Array('textarea', '*[Description', ['cols', 40, 'rows', 10], '', 'A short description of either what the problem is or what you want your code to do. You should include as much information as possible, links to other forums/sites and anything else that may be useful.', true);
  21.  
  22.  
  23.  
  24. var _widths = ['100%', '20%', '40%', '40%'];
  25.  
  26. var _posting_form = {
  27.  
  28. errors: new Array(),
  29.  
  30. init: function() {
  31. this.create_form();
  32. },
  33.  
  34. create_form: function() {
  35. // Create new post layout
  36. var _holder = document.createElement('table');
  37. _holder.setAttribute('className', 'border');
  38. _holder.setAttribute('class', 'border');
  39. _holder.setAttribute('cellSpacing','1');
  40. _holder.setAttribute('cellPadding', '4');
  41. _holder.setAttribute('align', 'center');
  42. _holder.setAttribute('width', _widths[0]);
  43. _holder.setAttribute('id', 'post_form_holder');
  44. _holder.appendChild(document.createElement('tbody'));
  45. _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  46. _holder.firstChild.lastChild.lastChild.className = 'title1';
  47. _holder.firstChild.lastChild.lastChild.colSpan = '3';
  48. _holder.firstChild.lastChild.lastChild.lastChild.size = '2';
  49. _holder.firstChild.lastChild.lastChild.lastChild.appendChild(document.createTextNode(_title));
  50. if(_description) {
  51. _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  52. _holder.firstChild.lastChild.lastChild.setAttribute('className', 'window1');
  53. _holder.firstChild.lastChild.lastChild.setAttribute('class', 'window1');
  54. _holder.firstChild.lastChild.lastChild.setAttribute('colSpan', '3');
  55. _holder.firstChild.lastChild.lastChild.lastChild.setAttribute('size', '2');
  56. _holder.firstChild.lastChild.lastChild.lastChild.innerHTML = _description;
  57. }
  58.  
  59. for(_f=0; _f<_fields.length; _f++) {
  60. switch(_fields[_f][0]) {
  61. case 'textarea' :
  62. var _tmp = document.createElement('textarea');
  63. if("undefined" != typeof _fields[_f][3] && _fields[_f][3] != "")
  64. _tmp.innerHTML= _fields[_f][3];
  65. break;
  66.  
  67. case 'select' :
  68. var _tmp = document.createElement('select');
  69. for(_o=0; _o<_fields[_f][3].length; _o++) {
  70. _tmp.options[_o] = new Option(_fields[_f][3][_o], _fields[_f][3][_o]);
  71. }
  72. break;
  73.  
  74. default :
  75. var _tmp = document.createElement('input');
  76. _tmp.type = 'text';
  77. if("undefined" != typeof _fields[_f][3] && _fields[_f][3] != "")
  78. _tmp.setAttribute('value', _fields[_f][3]);
  79. break;
  80. }
  81. _tmp.setAttribute('id', _f);
  82. if("undefined" != typeof _fields[_f][2] && _fields[_f][2].length > 0) {
  83. for(_a=0; _a<_fields[_f][2].length; _a++) {
  84. _tmp.setAttribute(_fields[_f][2][_a++], _fields[_f][2][_a]);
  85. }
  86. }
  87. var _class = 'window' + ((_f % 2 == 0)? '2' : '1');
  88. var _row = document.createElement('tr');
  89. _row.appendChild(document.createElement('td'));
  90. _row.lastChild.setAttribute('class', _class);
  91. _row.lastChild.setAttribute('className', _class);
  92. _row.lastChild.setAttribute('vAlign', 'top');
  93. _row.lastChild.setAttribute('width', _widths[1]);
  94. _row.lastChild.appendChild(document.createElement('font'));
  95. _row.lastChild.lastChild.setAttribute('size', '2');
  96. _row.lastChild.lastChild.style.fontWeight = 'bold';
  97. _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][1] + ':'));
  98. _row.appendChild(document.createElement('td'));
  99. _row.lastChild.setAttribute('class', _class);
  100. _row.lastChild.setAttribute('className', _class);
  101. _row.lastChild.setAttribute('width', _widths[2]);
  102. _row.lastChild.appendChild(document.createElement('font'));
  103. _row.lastChild.lastChild.setAttribute('size', '2');
  104. _row.lastChild.lastChild.appendChild(_tmp);
  105. _row.appendChild(document.createElement('td'));
  106. _row.lastChild.setAttribute('class', _class);
  107. _row.lastChild.setAttribute('className', _class);
  108. _row.lastChild.setAttribute('vAlign', 'top');
  109. _row.lastChild.setAttribute('width', _widths[3]);
  110. _row.lastChild.appendChild(document.createElement('font'));
  111. _row.lastChild.lastChild.size = '1';
  112. _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][4]));
  113. _holder.firstChild.appendChild(_row);
  114. }
  115. var _submit = document.createElement('tr');
  116. _submit.appendChild(document.createElement('td'));
  117. _submit.lastChild.setAttribute('class', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  118. _submit.lastChild.setAttribute('className', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  119. _submit.lastChild.setAttribute('align', 'center');
  120. _submit.lastChild.setAttribute('colSpan', 3);
  121. var _button = document.createElement('input');
  122. _button.setAttribute('type', 'button');
  123. _button.setAttribute('value', 'Post Message');
  124. _button.onclick = function() { _posting_form.post_it(); };
  125. _submit.lastChild.appendChild(_button);
  126. _holder.firstChild.appendChild(_submit);
  127. document.post_form.style.display = 'none';
  128. document.post_form.parentNode.insertBefore(_holder, document.post_form);
  129. },
  130.  
  131. post_it: function() {
  132. // create message and attempt to post it
  133. this.errors = new Array();
  134. document.post_form.message.value = document.post_form.subject.value = '';
  135. var _sub = document.getElementById('0').value;
  136. _fields[0][5] = true;
  137. document.post_form.subject.value = _sub;
  138. for(_f=0; _f<_fields.length; _f++) {
  139. if(document.getElementById(_f)) {
  140. _value = document.getElementById(_f).value;
  141. if(!_value || _value.match(/^s*$/)) {
  142. if(_f > 0 && _fields[_f][5])
  143. this.show_error('You have left the ' + _fields[_f][1] + ' option empty. This is a required field and as such must contain a value.');
  144. else
  145. _value = 'None';
  146. }
  147. document.post_form.message.value += '' + _fields[_f][1] + ': ' + _value + '\n\n';
  148. }
  149. }
  150. if(this.errors.length == 0)
  151. document.post_form.post.click();
  152. else
  153. this.show_error();
  154. },
  155.  
  156. show_error: function() {
  157. if("undefined" != typeof arguments[0] && arguments[0]) {
  158. this.errors.push(arguments[0]);
  159. } else {
  160. // Show Errors
  161. if(document.getElementById('status_holder')) {
  162. document.getElementById('status_holder_title').innerHTML = "An Error Has Occured";
  163. document.getElementById('status_holder_message').innerHTML = this.errors.join("<br />");
  164. document.getElementById('status_holder').style.display = 'block';
  165. }
  166. }
  167. }
  168. }
  169.  
  170.  
  171. if(document.post_form && location.href.match(/action\/post\/?$/) && vf_username != 'Guest') {
  172. _posting_form.init();
  173. }
  174.  
  175. //-->
  176. </script>
 
i've also tried it like this http://support.virtualforums.co.uk/board/database/topic/25/action/view_topic/page/3/predefined-posting-template-form/#reply-34
without editing it still wouldn't work {Confused} .

http://tropolis.virtualforums.co.uk/ <--- forum.

Image
click here We have 15 Different Skins/Templates for your vForum
Michael
Moderator
*****

[Avatar]
Recoding the future

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

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: A: R/M/W help with this code please (23rd Feb 08 at 12:16pm UTC)
which board is it in?
FreeUS
New Member
*

[Avatar]

Posts: 14
Status: Offline
Gender: Male
Location: California
Joined:  
Reputation: 0%  


pm
Re: A: R/M/W help with this code please (23rd Feb 08 at 12:49pm UTC)
He says it's in his Affliate Board footer.Maybe because it's in a sub board?
Michael
Moderator
*****

[Avatar]
Recoding the future

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

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: A: R/M/W help with this code please (23rd Feb 08 at 1:07pm UTC)
Try this:

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="http://capecoral.vforums.co.uk/board/general/topic/3/action/view_topic/page/1/rules/">Rules</a> before posting. If you break the rules, your thread will be locked and moved to a hidden board for dead codes. You are free to repost your code if you don\'t break the rules again. Repeatedly breaking the rules will result in a warning.';
  13.  
  14. var _fields = new Array(); var _f = 0;
  15. _fields[_f++] = new Array('input', '*Code Type', ['size', 40, 'maxLength', 50], '', 'Type of Code/Code Name', true);
  16.  
  17. _fields[_f++] = new Array('input', 'Forum Link', ['size', 40, 'maxLength', 50], '', 'Link to Your Forum', false);
  18. _fields[_f++] = new Array('input', 'Browser', ['size', 40, 'maxLength', 50], '', 'Browser that you use.', false);
  19.  
  20. _fields[_f++] = new Array('textarea', '*[Description', ['cols', 40, 'rows', 10], '', 'A short description of either what the problem is or what you want your code to do. You should include as much information as possible, links to other forums/sites and anything else that may be useful.', true);
  21.  
  22.  
  23.  
  24. var _widths = ['100%', '20%', '40%', '40%'];
  25.  
  26. var _posting_form = {
  27.  
  28. errors: new Array(),
  29.  
  30. init: function() {
  31. this.create_form();
  32. },
  33.  
  34. create_form: function() {
  35. // Create new post layout
  36. var _holder = document.createElement('table');
  37. _holder.setAttribute('className', 'border');
  38. _holder.setAttribute('class', 'border');
  39. _holder.setAttribute('cellSpacing','1');
  40. _holder.setAttribute('cellPadding', '4');
  41. _holder.setAttribute('align', 'center');
  42. _holder.setAttribute('width', _widths[0]);
  43. _holder.setAttribute('id', 'post_form_holder');
  44. _holder.appendChild(document.createElement('tbody'));
  45. _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  46. _holder.firstChild.lastChild.lastChild.className = 'title1';
  47. _holder.firstChild.lastChild.lastChild.colSpan = '3';
  48. _holder.firstChild.lastChild.lastChild.lastChild.size = '2';
  49. _holder.firstChild.lastChild.lastChild.lastChild.appendChild(document.createTextNode(_title));
  50. if(_description) {
  51. _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  52. _holder.firstChild.lastChild.lastChild.setAttribute('className', 'window1');
  53. _holder.firstChild.lastChild.lastChild.setAttribute('class', 'window1');
  54. _holder.firstChild.lastChild.lastChild.setAttribute('colSpan', '3');
  55. _holder.firstChild.lastChild.lastChild.lastChild.setAttribute('size', '2');
  56. _holder.firstChild.lastChild.lastChild.lastChild.innerHTML = _description;
  57. }
  58.  
  59. for(_f=0; _f<_fields.length; _f++) {
  60. switch(_fields[_f][0]) {
  61. case 'textarea' :
  62. var _tmp = document.createElement('textarea');
  63. if("undefined" != typeof _fields[_f][3] && _fields[_f][3] != "")
  64. _tmp.innerHTML= _fields[_f][3];
  65. break;
  66.  
  67. case 'select' :
  68. var _tmp = document.createElement('select');
  69. for(_o=0; _o<_fields[_f][3].length; _o++) {
  70. _tmp.options[_o] = new Option(_fields[_f][3][_o], _fields[_f][3][_o]);
  71. }
  72. break;
  73.  
  74. default :
  75. var _tmp = document.createElement('input');
  76. _tmp.type = 'text';
  77. if("undefined" != typeof _fields[_f][3] && _fields[_f][3] != "")
  78. _tmp.setAttribute('value', _fields[_f][3]);
  79. break;
  80. }
  81. _tmp.setAttribute('id', _f);
  82. if("undefined" != typeof _fields[_f][2] && _fields[_f][2].length > 0) {
  83. for(_a=0; _a<_fields[_f][2].length; _a++) {
  84. _tmp.setAttribute(_fields[_f][2][_a++], _fields[_f][2][_a]);
  85. }
  86. }
  87. var _class = 'window' + ((_f % 2 == 0)? '2' : '1');
  88. var _row = document.createElement('tr');
  89. _row.appendChild(document.createElement('td'));
  90. _row.lastChild.setAttribute('class', _class);
  91. _row.lastChild.setAttribute('className', _class);
  92. _row.lastChild.setAttribute('vAlign', 'top');
  93. _row.lastChild.setAttribute('width', _widths[1]);
  94. _row.lastChild.appendChild(document.createElement('font'));
  95. _row.lastChild.lastChild.setAttribute('size', '2');
  96. _row.lastChild.lastChild.style.fontWeight = 'bold';
  97. _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][1] + ':'));
  98. _row.appendChild(document.createElement('td'));
  99. _row.lastChild.setAttribute('class', _class);
  100. _row.lastChild.setAttribute('className', _class);
  101. _row.lastChild.setAttribute('width', _widths[2]);
  102. _row.lastChild.appendChild(document.createElement('font'));
  103. _row.lastChild.lastChild.setAttribute('size', '2');
  104. _row.lastChild.lastChild.appendChild(_tmp);
  105. _row.appendChild(document.createElement('td'));
  106. _row.lastChild.setAttribute('class', _class);
  107. _row.lastChild.setAttribute('className', _class);
  108. _row.lastChild.setAttribute('vAlign', 'top');
  109. _row.lastChild.setAttribute('width', _widths[3]);
  110. _row.lastChild.appendChild(document.createElement('font'));
  111. _row.lastChild.lastChild.size = '1';
  112. _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][4]));
  113. _holder.firstChild.appendChild(_row);
  114. }
  115. var _submit = document.createElement('tr');
  116. _submit.appendChild(document.createElement('td'));
  117. _submit.lastChild.setAttribute('class', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  118. _submit.lastChild.setAttribute('className', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  119. _submit.lastChild.setAttribute('align', 'center');
  120. _submit.lastChild.setAttribute('colSpan', 3);
  121. var _button = document.createElement('input');
  122. _button.setAttribute('type', 'button');
  123. _button.setAttribute('value', 'Post Message');
  124. _button.onclick = function() { _posting_form.post_it(); };
  125. _submit.lastChild.appendChild(_button);
  126. _holder.firstChild.appendChild(_submit);
  127. document.post_form.style.display = 'none';
  128. document.post_form.parentNode.insertBefore(_holder, document.post_form);
  129. },
  130.  
  131. post_it: function() {
  132. // create message and attempt to post it
  133. this.errors = new Array();
  134. document.post_form.message.value = document.post_form.subject.value = '';
  135. var _sub = document.getElementById('0').value;
  136. _fields[0][5] = true;
  137. document.post_form.subject.value = _sub;
  138. for(_f=0; _f<_fields.length; _f++) {
  139. if(document.getElementById(_f)) {
  140. _value = document.getElementById(_f).value;
  141. if(!_value || _value.match(/^s*$/)) {
  142. if(_f > 0 && _fields[_f][5])
  143. this.show_error('You have left the ' + _fields[_f][1] + ' option empty. This is a required field and as such must contain a value.');
  144. else
  145. _value = 'None';
  146. }
  147. document.post_form.message.value += '' + _fields[_f][1] + ': ' + _value + '\n\n';
  148. }
  149. }
  150. if(this.errors.length == 0)
  151. document.post_form.post.click();
  152. else
  153. this.show_error();
  154. },
  155.  
  156. show_error: function() {
  157. if("undefined" != typeof arguments[0] && arguments[0]) {
  158. this.errors.push(arguments[0]);
  159. } else {
  160. // Show Errors
  161. if(document.getElementById('status_holder')) {
  162. document.getElementById('status_holder_title').innerHTML = "An Error Has Occured";
  163. document.getElementById('status_holder_message').innerHTML = this.errors.join("<br />");
  164. document.getElementById('status_holder').style.display = 'block';
  165. }
  166. }
  167. }
  168. }
  169.  
  170.  
  171. if(document.post_form && location.href.match(/action\/post\/?$/) && vf_username != 'Guest') {
  172. _posting_form.init();
  173. }
  174.  
  175. //-->
  176. </script>
 
CåñåÐå™
Full Member
***

[Avatar]

Posts: 427
Status: Offline
Gender: Male
Location: Toronto Ontario
Joined:  
Reputation: 7%  


pmwww
Re: A: R/M/W help with this code please (23rd Feb 08 at 2:13pm UTC)
Ok i've tried it Wrighty and it didn't work but i did try it in a board on the main page (not a sub-board) and it works perfectly . FreeUS is right for some reason it doesn't want to work in a sub-board. Right now the code is out .

Image
click here We have 15 Different Skins/Templates for your vForum
CåñåÐå™
Full Member
***

[Avatar]

Posts: 427
Status: Offline
Gender: Male
Location: Toronto Ontario
Joined:  
Reputation: 7%  


pmwww
Re: A: R/M/W help with this code please (23rd Feb 08 at 4:32pm UTC)
Ok my Affiliate board is no longer an sub-board so the code will now work fine.
Can you please luck this thread and my other thread ( http://support.virtualforums.co.uk/board/coderequest/topic/9562/action/view_topic/page/2/ross-affiliate-posting-form-to-be-converted/#reply-17 )

Thank you Wrighty and FreeUS, Marc and Ross for the help {Grin} .

Image
click here We have 15 Different Skins/Templates for your vForum
 Printable View

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