vForums Support Banner


Visit Base Classics - Gaming Chairs

 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Code Requests & Support :: Predefined Posting template - View Topic
Topic Rating: *****
Printable View
Nick
Very Senior Member
*****

[Avatar]

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


pmwww
Predefined Posting template (8th Jan 11 at 3:58am UTC)
Resolved
Ok, I have an issue with the posting template. It's not putting it as a list, instead it's just putting it all on one line: http://support.ihosting.co.cc/signup/7/this-is-your-site-name-example-please-read

Here is the code:
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 = 'Hosting Sign Up';
  9. var _description = 'Please ensure you have a read of the <a href="http://ihosting.co.cc/tou.php">Terms of Service</a> before signing up. Please fill out everything below. A Password will be emailed and sent by PM to ensure you get it.';
  10. var _fields = new Array(); var _f = 0;
  11.     _fields[_f++] = new Array('input', 'Site Name', ['size', 40, 'maxLength', 50], '', 'What is the name of your site?', false);
  12.     _fields[_f++] = new Array('select', 'Packages', false, ['Small', 'Medium', 'Large',], 'Select the hosting package you want.', true);
  13.     _fields[_f++] = new Array('input', 'Site URL', ['size', 40, 'maxLength', 200], false, 'What is the domain url of your site? If you want a subdomain, IE: yourdomain.ihosting.co.cc then just put the name of your site.', false);
  14.     _fields[_f++] = new Array('input', 'Username', ['size', 40, 'maxLength', 50], '', 'What is your cPanels username?', false);
  15.     _fields[_f++] = new Array('input', 'Email', ['size', 40, 'maxLength', 50], '', 'What is your email?', false);
  16. var _widths = ['100%', '20%', '40%', '40%'];
  17. var _posting_form = {
  18.     errors: new Array(),
  19.     init: function() {
  20.         this.create_form();
  21.     },
  22.     
  23.     create_form: function() {
  24.         // Create new post layout
  25.         var _holder = document.createElement('table');
  26.         _holder.setAttribute('className', 'border');
  27.         _holder.setAttribute('class', 'border');
  28.         _holder.setAttribute('cellSpacing','1');
  29.         _holder.setAttribute('cellPadding', '4');
  30.         _holder.setAttribute('align', 'center');
  31.         _holder.setAttribute('width', _widths[0]);
  32.         _holder.setAttribute('id', 'post_form_holder');
  33.         _holder.appendChild(document.createElement('tbody'));
  34.         _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  35.         _holder.firstChild.lastChild.lastChild.className = 'title1';
  36.         _holder.firstChild.lastChild.lastChild.colSpan = '3';
  37.         _holder.firstChild.lastChild.lastChild.lastChild.size = '2';
  38.         _holder.firstChild.lastChild.lastChild.lastChild.appendChild(document.createTextNode(_title));
  39.         if(_description) {
  40.             _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
  41.             _holder.firstChild.lastChild.lastChild.setAttribute('className', 'window1');
  42.             _holder.firstChild.lastChild.lastChild.setAttribute('class', 'window1');
  43.             _holder.firstChild.lastChild.lastChild.setAttribute('colSpan', '3');
  44.             _holder.firstChild.lastChild.lastChild.lastChild.setAttribute('size', '2');
  45.             _holder.firstChild.lastChild.lastChild.lastChild.innerHTML = _description;
  46.         }
  47.         
  48.         for(_f=0; _f<_fields.length; _f++) {
  49.             switch(_fields[_f][0]) {
  50.                 case 'textarea' :
  51.                     var _tmp = document.createElement('textarea');
  52.                 break;
  53.                 
  54.                 case 'select' :
  55.                     var _tmp = document.createElement('select');
  56.                     for(_o=0; _o<_fields[_f][3].length; _o++) {
  57.                         _tmp.options[_o] = new Option(_fields[_f][3][_o], _fields[_f][3][_o]);
  58.                     }
  59.                 break;
  60.                 
  61.                 default :
  62.                     var _tmp = document.createElement('input');
  63.                     _tmp.type = 'text';
  64.                     if("undefined" != typeof _fields[_f][3] && _fields[_f][3] != "")
  65.                         _tmp.setAttribute('value', _fields[_f][3]);
  66.                 break;
  67.             }
  68.             _tmp.setAttribute('id', _f);
  69.             if("undefined" != typeof _fields[_f][2] && _fields[_f][2].length > 0) {
  70.                 for(_a=0; _a<_fields[_f][2].length; _a++) {
  71.                     _tmp.setAttribute(_fields[_f][2][_a++], _fields[_f][2][_a]);
  72.                 }
  73.             }
  74.             var _class = 'window' + ((_f % 2 == 0)? '2' : '1');
  75.             var _row = document.createElement('tr');
  76.             _row.appendChild(document.createElement('td'));
  77.             _row.lastChild.setAttribute('class', _class);
  78.             _row.lastChild.setAttribute('className', _class);
  79.             _row.lastChild.setAttribute('vAlign', 'top');
  80.             _row.lastChild.setAttribute('width', _widths[1]);
  81.             _row.lastChild.appendChild(document.createElement('font'));
  82.             _row.lastChild.lastChild.setAttribute('size', '2');
  83.             _row.lastChild.lastChild.style.fontWeight = 'bold';
  84.             _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][1] + ':'));
  85.             _row.appendChild(document.createElement('td'));
  86.             _row.lastChild.setAttribute('class', _class);
  87.             _row.lastChild.setAttribute('className', _class);
  88.             _row.lastChild.setAttribute('width', _widths[2]);
  89.             _row.lastChild.appendChild(document.createElement('font'));
  90.             _row.lastChild.lastChild.setAttribute('size', '2');
  91.             _row.lastChild.lastChild.appendChild(_tmp);
  92.             _row.appendChild(document.createElement('td'));
  93.             _row.lastChild.setAttribute('class', _class);
  94.             _row.lastChild.setAttribute('className', _class);
  95.             _row.lastChild.setAttribute('vAlign', 'top');
  96.             _row.lastChild.setAttribute('width', _widths[3]);
  97.             _row.lastChild.appendChild(document.createElement('font'));
  98.             _row.lastChild.lastChild.size = '1';
  99.             _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][4]));
  100.             _holder.firstChild.appendChild(_row);
  101.         }
  102.         var _submit = document.createElement('tr');
  103.         _submit.appendChild(document.createElement('td'));
  104.         _submit.lastChild.setAttribute('class', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  105.         _submit.lastChild.setAttribute('className', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
  106.         _submit.lastChild.setAttribute('align', 'center');
  107.         _submit.lastChild.setAttribute('colSpan', 3);
  108.         var _button = document.createElement('input');
  109.         _button.setAttribute('type', 'button');
  110.         _button.setAttribute('value', 'Post Message');
  111.         _button.onclick = function() { _posting_form.post_it(); };
  112.         _submit.lastChild.appendChild(_button);
  113.         _holder.firstChild.appendChild(_submit);
  114.         document.post_form.style.display = 'none';
  115.         document.post_form.parentNode.insertBefore(_holder,  document.post_form);
  116.     },
  117.     
  118.     post_it: function() {
  119.         // create message and attempt to post it
  120.         this.errors = new Array();
  121.         document.post_form.message.value = document.post_form.subject.value = '';
  122.         var _sub = document.getElementById('0').value;
  123.         _fields[0][5] = true;
  124.         document.post_form.subject.value    = _sub;
  125.         for(_f=0; _f<_fields.length; _f++) {
  126.             if(document.getElementById(_f)) {
  127.                 _value = document.getElementById(_f).value;
  128.                 if(!_value || _value.match(/^s*$/)) {
  129.                     if(_f > 0 && _fields[_f][5])
  130.                         this.show_error('You have left the ' + _fields[_f][1] + ' option empty. This is a required field and as such must contain a value.');
  131.                     else
  132.                         _value = 'None';
  133.                 }
  134.                 document.post_form.message.value += '' + _fields[_f][1] + ': ' + _value + 'nn';
  135.             }
  136.         }
  137.         if(this.errors.length == 0)
  138.             document.post_form.post.click();
  139.         else
  140.             this.show_error();
  141.     },
  142.     
  143.     show_error: function() {
  144.         if("undefined" != typeof arguments[0] && arguments[0]) {
  145.             this.errors.push(arguments[0]);
  146.         } else {
  147.             // Show Errors
  148.             if(document.getElementById('status_holder')) {
  149.                 document.getElementById('status_holder_title').innerHTML = "An Error Has Occured";
  150.                 document.getElementById('status_holder_message').innerHTML = this.errors.join("<br />");
  151.                 document.getElementById('status_holder').style.display = 'block';
  152.             }
  153.         }
  154.     }
  155. }
  156. if(document.post_form && location.href.match(/action\/post\/?$/) && vf_username != 'Guest') {
  157.     _posting_form.init();
  158. }
  159. //-->
  160. </script>
 

Nick
Very Senior Member
*****

[Avatar]

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


pmwww
Re: Predefined Posting template (18th Jan 11 at 2:02am UTC)
Bump, please tell me what is wrong with this?
Nick
Very Senior Member
*****

[Avatar]

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


pmwww
Re: Predefined Posting template (18th Jan 11 at 3:20pm UTC)
Nevermind I got it. The original Code from the Code Database is messing up. As I went to an older forum of mine, and tested the code out, and this doesn't show up:

Quote:
Site Name: This is your site name - Example - Please readnnPackages: SmallnnSite URL: http://yourdomain.com or http://yourdomain.ihosting.co.ccnnUsername: usernamennEmail: someemail@yourhost.comnn


I also tested the code directly without changing anything and it does the same above: http://dmtesting.vforums.co.uk/general/12/testing


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 (22nd Jan 11 at 4:40pm UTC)
It looks like the UBBC parser is stripping the \n to be n :/

I'll go take a look at the code that is in the thread. {Smile}

---

I have updated the code. {Smile}


Nick
Very Senior Member
*****

[Avatar]

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


pmwww
Re: Predefined Posting template (22nd Jan 11 at 5:38pm UTC)
Oh Ok, well at least it's fixed now! {Smile}
Vanquish
Junior Member
**

[Avatar]

Posts: 64
Status: Offline
Gender: Male
Location: Northern Ireland
Age: 35
Joined:  
Reputation: 10%  


pmvForum
Re: Predefined Posting template (5th May 11 at 5:35pm UTC)
Ok, Im confused as to why this code wont work.
I copied the code as it is from one forum, where the predefined posting form displays.
When I paste it onto my forum: Boost, it doesnt display the form when creating a new topic.

Not sure why, as I have copied the code as it is from both here and Tru Visions where it displays correctly.

Edit: Link to board on my forum where it doesnt display:
http://boost.vforums.co.uk/Dir

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 (6th May 11 at 12:14am UTC)
Shows up fine for me in Google Chrome 11.0.696.60 and FireFox 4.0

Though I cannot see the post http://boost.vforums.co.uk/Dir/44/forum-directory what so ever. Which oddly when I click into it, my browser gives me this link instead: http://boost.vforums.co.uk/directory
Vanquish
Junior Member
**

[Avatar]

Posts: 64
Status: Offline
Gender: Male
Location: Northern Ireland
Age: 35
Joined:  
Reputation: 10%  


pmvForum
Re: Predefined Posting template (6th May 11 at 6:53am UTC)
Hmm, seems to work fine for me in work too, just not at home.
Possibly another Firefox 4 error, but cant be too sure.
Running Firefox 3 in work.


Ok, the cause of the problem seems to be when using the root admin account.
It displays properly if I login in to my test member account.

Regarding the post, that basically makes the thread link take you to another board.


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 (6th May 11 at 8:34pm UTC)
Oh I see, well that's different.
 Printable View

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