vForums Support :: Programming & Coding :: Code Requests & Support :: Code not working! - View Topic
 |  |
| Nick Very Senior Member
    
![[Avatar]](http://uploads.vforums.co.uk/forums/support/f_5e7b1402b305d883af97446b2fedc6c2_1-eog.jpeg) Posts: 3,013 Status: Offline Gender: Male Location: vForums Age: 35 Joined:
pmwww | Code not working! (16th Dec 09 at 10:20pm UTC) Resolved | | For some reason this will not work I made sure all fields were correct and such but it still does not work. http://forsakendesire.vforums.co.uk/board/profile/action/post
 Code: - <script type="text/javascript">
- <!--
-
- /* Predefined Posting Template/Form
- Created by Ross of vForums
- http://virtualforums.co.uk
- Please do not repost outside of
- vForums support without permission */
-
- var _title = 'Profile Template';
-
- var _description = '';
-
- var _fields = new Array(); var _f = 0;
-
- _fields[_f++] = new Array('input', 'Name', ['size', 40, 'maxLength', 50], '', 'Name of your Character', false);
- _fields[_f++] = new Array('input', 'Age', ['size', 40, 'maxLength', 50], '', 'Age of you Character', false);
- _fields[_f++] = new Array('input', 'Gender', ['size', 40, 'maxLength', 50], '', 'What is the Gender of your Character?', false);
- _fields[_f++] = new Array('input', 'Home Town', ['size', 40, 'maxLength', 250], '', 'What is your Characters Home Town?', false);
- _fields[_f++] = new Array('textarea', 'Occupation', ['cols', 40, 'rows', 2], '', 'What Occupation does your character have?', false);
- _fields[_f++] = new Array('input', 'Alliance', ['size', 40, 'maxLength', 350], '', 'Pro/Anti ShinRa/Avalanche/Other?', false);
- _fields[_f++] = new Array('textarea', 'Appearance', ['cols', 40, 'rows', 4], '', 'Your Characters Appearance.(If you have pictures link them do NOT post them as [img][/img] Thanks))', false);
- _fields[_f++] = new Array('textarea', 'Personality', ['cols', 40, 'rows', 4], '', 'What is your characters personality?', false);
- _fields[_f++] = new Array('input', 'Strength', ['size', 40, 'maxLength', 100], '', 'Characters Strength', false);
- _fields[_f++] = new Array('input', 'Weakness', ['size', 40, 'maxLength', 100], '', 'Characters Weakness', false);
- _fields[_f++] = new Array('input', 'Weapon', ['size', 40, 'maxLength', 150], '', 'Characters Weapon (If you have pictures link them do NOT post them as [img][/img] Thanks)', false);
- _fields[_f++] = new Array('input', 'Materia in weapon', ['size', 40, 'maxLength', 150], '', 'What Materia do you have in your weapon?', false);
- _fields[_f++] = new Array('input', 'Armor', ['size', 40, 'maxLength', 150], '', 'Characters Armor.', false);
- _fields[_f++] = new Array('input', 'Materia in Armor', ['size', 40, 'maxLength', 150], '', 'Materia in Characters Armor.', false);
- _fields[_f++] = new Array('input', 'Accessory', ['size', 40, 'maxLength', 150], '', 'Does your character have any Accessories?', false);
- _fields[_f++] = new Array('textarea', 'History', ['cols', 40, 'rows', 4], '', 'What is your characters History?', false);
- _fields[_f++] = new Array('textarea', 'Anything you would like to add?', ['cols', 40, 'rows', 4], '', 'Post any useful information about you or your character. (If any.)', false);
- _fields[_f++] = new Array('input', 'Is this your 1st, 2nd, or 3rd profile application?', ['size', 40, 'maxLength', 150], '', 'Don'\t lie. We will find out!', false);
- _fields[_f++] = new Array('input', 'Time Zone', ['size', 40, 'maxLength', 150], '', 'Just a piece of helpful information', false);
- _fields[_f++] = new Array('input', 'How often can you be online?', ['size', 40, 'maxLength', 150], '', '&;nsbp', false);
-
- var _widths = ['100%', '20%', '40%', '40%'];
-
- var _posting_form = {
-
- errors: new Array(),
-
- init: function() {
- this.create_form();
- },
-
- create_form: function() {
- // Create new post layout
- var _holder = document.createElement('table');
- _holder.setAttribute('className', 'border');
- _holder.setAttribute('class', 'border');
- _holder.setAttribute('cellSpacing','1');
- _holder.setAttribute('cellPadding', '4');
- _holder.setAttribute('align', 'center');
- _holder.setAttribute('width', _widths[0]);
- _holder.setAttribute('id', 'post_form_holder');
- _holder.appendChild(document.createElement('tbody'));
- _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
- _holder.firstChild.lastChild.lastChild.className = 'title1';
- _holder.firstChild.lastChild.lastChild.colSpan = '3';
- _holder.firstChild.lastChild.lastChild.lastChild.size = '2';
- _holder.firstChild.lastChild.lastChild.lastChild.appendChild(document.createTextNode(_title));
- if(_description) {
- _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
- _holder.firstChild.lastChild.lastChild.setAttribute('className', 'window1');
- _holder.firstChild.lastChild.lastChild.setAttribute('class', 'window1');
- _holder.firstChild.lastChild.lastChild.setAttribute('colSpan', '3');
- _holder.firstChild.lastChild.lastChild.lastChild.setAttribute('size', '2');
- _holder.firstChild.lastChild.lastChild.lastChild.innerHTML = _description;
- }
-
- for(_f=0; _f<_fields.length; _f++) {
- switch(_fields[_f][0]) {
- case 'textarea' :
- var _tmp = document.createElement('textarea');
- break;
-
- case 'select' :
- var _tmp = document.createElement('select');
- for(_o=0; _o<_fields[_f][3].length; _o++) {
- _tmp.options[_o] = new Option(_fields[_f][3][_o], _fields[_f][3][_o]);
- }
- break;
-
- default :
- var _tmp = document.createElement('input');
- _tmp.type = 'text';
- if("undefined" != typeof _fields[_f][3] && _fields[_f][3] != "")
- _tmp.setAttribute('value', _fields[_f][3]);
- break;
- }
- _tmp.setAttribute('id', _f);
- if("undefined" != typeof _fields[_f][2] && _fields[_f][2].length > 0) {
- for(_a=0; _a<_fields[_f][2].length; _a++) {
- _tmp.setAttribute(_fields[_f][2][_a++], _fields[_f][2][_a]);
- }
- }
- var _class = 'window' + ((_f % 2 == 0)? '2' : '1');
- var _row = document.createElement('tr');
- _row.appendChild(document.createElement('td'));
- _row.lastChild.setAttribute('class', _class);
- _row.lastChild.setAttribute('className', _class);
- _row.lastChild.setAttribute('vAlign', 'top');
- _row.lastChild.setAttribute('width', _widths[1]);
- _row.lastChild.appendChild(document.createElement('font'));
- _row.lastChild.lastChild.setAttribute('size', '2');
- _row.lastChild.lastChild.style.fontWeight = 'bold';
- _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][1] + ':'));
- _row.appendChild(document.createElement('td'));
- _row.lastChild.setAttribute('class', _class);
- _row.lastChild.setAttribute('className', _class);
- _row.lastChild.setAttribute('width', _widths[2]);
- _row.lastChild.appendChild(document.createElement('font'));
- _row.lastChild.lastChild.setAttribute('size', '2');
- _row.lastChild.lastChild.appendChild(_tmp);
- _row.appendChild(document.createElement('td'));
- _row.lastChild.setAttribute('class', _class);
- _row.lastChild.setAttribute('className', _class);
- _row.lastChild.setAttribute('vAlign', 'top');
- _row.lastChild.setAttribute('width', _widths[3]);
- _row.lastChild.appendChild(document.createElement('font'));
- _row.lastChild.lastChild.size = '1';
- _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][4]));
- _holder.firstChild.appendChild(_row);
- }
- var _submit = document.createElement('tr');
- _submit.appendChild(document.createElement('td'));
- _submit.lastChild.setAttribute('class', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
- _submit.lastChild.setAttribute('className', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
- _submit.lastChild.setAttribute('align', 'center');
- _submit.lastChild.setAttribute('colSpan', 3);
- var _button = document.createElement('input');
- _button.setAttribute('type', 'button');
- _button.setAttribute('value', 'Post Message');
- _button.onclick = function() { _posting_form.post_it(); };
- _submit.lastChild.appendChild(_button);
- _holder.firstChild.appendChild(_submit);
- document.post_form.style.display = 'none';
- document.post_form.parentNode.insertBefore(_holder, document.post_form);
- },
-
- post_it: function() {
- // create message and attempt to post it
- this.errors = new Array();
- document.post_form.message.value = document.post_form.subject.value = '';
- var _sub = document.getElementById('0').value;
- _fields[0][5] = true;
- document.post_form.subject.value = _sub;
- for(_f=0; _f<_fields.length; _f++) {
- if(document.getElementById(_f)) {
- _value = document.getElementById(_f).value;
- if(!_value || _value.match(/^s*$/)) {
- if(_f > 0 && _fields[_f][5])
- this.show_error('You have left the ' + _fields[_f][1] + ' option empty. This is a required field and as such must contain a value.');
- else
- _value = '[i]None[/i]';
- }
- document.post_form.message.value += '[b]' + _fields[_f][1] + ':[/b] ' + _value + '\n\n';
- }
- }
- if(this.errors.length == 0)
- document.post_form.post.click();
- else
- this.show_error();
- },
-
- show_error: function() {
- if("undefined" != typeof arguments[0] && arguments[0]) {
- this.errors.push(arguments[0]);
- } else {
- // Show Errors
- if(document.getElementById('status_holder')) {
- document.getElementById('status_holder_title').innerHTML = "An Error Has Occured";
- document.getElementById('status_holder_message').innerHTML = this.errors.join("<br />");
- document.getElementById('status_holder').style.display = 'block';
- }
- }
- }
- }
-
-
-
- if(document.post_form && location.href.match(/action\/post\/?$/) && vf_username != 'Guest') {
- _posting_form.init();
- }
- //-->
- </script>
but it works here: http://forsakendesire.vforums.co.uk/board/affiliate/action/post I don't see what I did wrong though. | |
| Michael Moderator
    
![[Avatar]](http://av.wservices.co.uk/av.png) Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
  
pmvForum | Re: Code not working! (17th Dec 09 at 1:47am UTC) | | _fields[_f++] = new Array('input', 'Is this your 1st, 2nd, or 3rd profile application?', ['size', 40, 'maxLength', 150], '', 'Don'\t lie. We will find out!', false);
You failed to escape the ' correctly. Should be:
_fields[_f++] = new Array('input', 'Is this your 1st, 2nd, or 3rd profile application?', ['size', 40, 'maxLength', 150], '', 'Don\'t lie. We will find out!', false); | |
| Nick Very Senior Member
    
![[Avatar]](http://uploads.vforums.co.uk/forums/support/f_5e7b1402b305d883af97446b2fedc6c2_1-eog.jpeg) Posts: 3,013 Status: Offline Gender: Male Location: vForums Age: 35 Joined:
pmwww | Re: Code not working! (17th Dec 09 at 2:44am UTC) | | Yeah I knew about that, for some reason I forgot to edit the OP, Here is the code that I have fixed but still does not work:
 Code: - <script type="text/javascript">
- <!--
-
- /* Predefined Posting Template/Form
- Created by Ross of vForums
- http://virtualforums.co.uk
- Please do not repost outside of
- vForums support without permission */
-
- var _title = 'Profile Template';
-
- var _description = '';
-
- var _fields = new Array(); var _f = 0;
-
- _fields[_f++] = new Array('input', 'Name', ['size', 40, 'maxLength', 50], '', 'Name of your Character', false);
- _fields[_f++] = new Array('input', 'Age', ['size', 40, 'maxLength', 50], '', 'Age of you Character', false);
- _fields[_f++] = new Array('input', 'Gender', ['size', 40, 'maxLength', 50], '', 'What is the Gender of your Character?', false);
- _fields[_f++] = new Array('input', 'Home Town', ['size', 40, 'maxLength', 250], '', 'What is your Characters Home Town?', false);
- _fields[_f++] = new Array('textarea', 'Occupation', ['cols', 40, 'rows', 2], '', 'What Occupation does your character have?', false);
- _fields[_f++] = new Array('input', 'Alliance', ['size', 40, 'maxLength', 350], '', 'Pro/Anti ShinRa/Avalanche/Other?', false);
- _fields[_f++] = new Array('textarea', 'Appearance', ['cols', 40, 'rows', 4], '', 'Your Characters Appearance. If you have pictures link them do NOT post them as img links Thanks.', false);
- _fields[_f++] = new Array('textarea', 'Personality', ['cols', 40, 'rows', 4], '', 'What is your characters personality?', false);
- _fields[_f++] = new Array('input', 'Strength', ['size', 40, 'maxLength', 100], '', 'Characters Strength', false);
- _fields[_f++] = new Array('input', 'Weakness', ['size', 40, 'maxLength', 100], '', 'Characters Weakness', false);
- _fields[_f++] = new Array('input', 'Weapon', ['size', 40, 'maxLength', 150], '', 'Characters Weapon If you have pictures link them do NOT post them as img links Thanks', false);
- _fields[_f++] = new Array('input', 'Materia in weapon', ['size', 40, 'maxLength', 150], '', 'What Materia do you have in your weapon?', false);
- _fields[_f++] = new Array('input', 'Armor', ['size', 40, 'maxLength', 150], '', 'Characters Armor.', false);
- _fields[_f++] = new Array('input', 'Materia in Armor', ['size', 40, 'maxLength', 150], '', 'Materia in Characters Armor.', false);
- _fields[_f++] = new Array('input', 'Accessory', ['size', 40, 'maxLength', 150], '', 'Does your character have any Accessories?', false);
- _fields[_f++] = new Array('textarea', 'History', ['cols', 40, 'rows', 4], '', 'What is your characters History?', false);
- _fields[_f++] = new Array('textarea', 'Anything you would like to add?', ['cols', 40, 'rows', 4], '', 'Post any useful information about you or your character. (If any.)', false);
- _fields[_f++] = new Array('input', 'Is this your 1st, 2nd, or 3rd profile application?', ['size', 40, 'maxLength', 150], '', 'Don'\t lie. We will find out!', false);
- _fields[_f++] = new Array('input', 'Time Zone', ['size', 40, 'maxLength', 150], '', 'Just a piece of helpful information', false);
- _fields[_f++] = new Array('input', 'How often can you be online?', ['size', 40, 'maxLength', 150], '', '..', false);
-
- var _widths = ['100%', '20%', '40%', '40%'];
-
- var _posting_form = {
-
- errors: new Array(),
-
- init: function() {
- this.create_form();
- },
-
- create_form: function() {
- // Create new post layout
- var _holder = document.createElement('table');
- _holder.setAttribute('className', 'border');
- _holder.setAttribute('class', 'border');
- _holder.setAttribute('cellSpacing','1');
- _holder.setAttribute('cellPadding', '4');
- _holder.setAttribute('align', 'center');
- _holder.setAttribute('width', _widths[0]);
- _holder.setAttribute('id', 'post_form_holder');
- _holder.appendChild(document.createElement('tbody'));
- _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
- _holder.firstChild.lastChild.lastChild.className = 'title1';
- _holder.firstChild.lastChild.lastChild.colSpan = '3';
- _holder.firstChild.lastChild.lastChild.lastChild.size = '2';
- _holder.firstChild.lastChild.lastChild.lastChild.appendChild(document.createTextNode(_title));
- if(_description) {
- _holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
- _holder.firstChild.lastChild.lastChild.setAttribute('className', 'window1');
- _holder.firstChild.lastChild.lastChild.setAttribute('class', 'window1');
- _holder.firstChild.lastChild.lastChild.setAttribute('colSpan', '3');
- _holder.firstChild.lastChild.lastChild.lastChild.setAttribute('size', '2');
- _holder.firstChild.lastChild.lastChild.lastChild.innerHTML = _description;
- }
-
- for(_f=0; _f<_fields.length; _f++) {
- switch(_fields[_f][0]) {
- case 'textarea' :
- var _tmp = document.createElement('textarea');
- break;
-
- case 'select' :
- var _tmp = document.createElement('select');
- for(_o=0; _o<_fields[_f][3].length; _o++) {
- _tmp.options[_o] = new Option(_fields[_f][3][_o], _fields[_f][3][_o]);
- }
- break;
-
- default :
- var _tmp = document.createElement('input');
- _tmp.type = 'text';
- if("undefined" != typeof _fields[_f][3] && _fields[_f][3] != "")
- _tmp.setAttribute('value', _fields[_f][3]);
- break;
- }
- _tmp.setAttribute('id', _f);
- if("undefined" != typeof _fields[_f][2] && _fields[_f][2].length > 0) {
- for(_a=0; _a<_fields[_f][2].length; _a++) {
- _tmp.setAttribute(_fields[_f][2][_a++], _fields[_f][2][_a]);
- }
- }
- var _class = 'window' + ((_f % 2 == 0)? '2' : '1');
- var _row = document.createElement('tr');
- _row.appendChild(document.createElement('td'));
- _row.lastChild.setAttribute('class', _class);
- _row.lastChild.setAttribute('className', _class);
- _row.lastChild.setAttribute('vAlign', 'top');
- _row.lastChild.setAttribute('width', _widths[1]);
- _row.lastChild.appendChild(document.createElement('font'));
- _row.lastChild.lastChild.setAttribute('size', '2');
- _row.lastChild.lastChild.style.fontWeight = 'bold';
- _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][1] + ':'));
- _row.appendChild(document.createElement('td'));
- _row.lastChild.setAttribute('class', _class);
- _row.lastChild.setAttribute('className', _class);
- _row.lastChild.setAttribute('width', _widths[2]);
- _row.lastChild.appendChild(document.createElement('font'));
- _row.lastChild.lastChild.setAttribute('size', '2');
- _row.lastChild.lastChild.appendChild(_tmp);
- _row.appendChild(document.createElement('td'));
- _row.lastChild.setAttribute('class', _class);
- _row.lastChild.setAttribute('className', _class);
- _row.lastChild.setAttribute('vAlign', 'top');
- _row.lastChild.setAttribute('width', _widths[3]);
- _row.lastChild.appendChild(document.createElement('font'));
- _row.lastChild.lastChild.size = '1';
- _row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][4]));
- _holder.firstChild.appendChild(_row);
- }
- var _submit = document.createElement('tr');
- _submit.appendChild(document.createElement('td'));
- _submit.lastChild.setAttribute('class', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
- _submit.lastChild.setAttribute('className', 'window' + (((_f+1) % 2 == 0)? '1' : '2'));
- _submit.lastChild.setAttribute('align', 'center');
- _submit.lastChild.setAttribute('colSpan', 3);
- var _button = document.createElement('input');
- _button.setAttribute('type', 'button');
- _button.setAttribute('value', 'Post Message');
- _button.onclick = function() { _posting_form.post_it(); };
- _submit.lastChild.appendChild(_button);
- _holder.firstChild.appendChild(_submit);
- document.post_form.style.display = 'none';
- document.post_form.parentNode.insertBefore(_holder, document.post_form);
- },
-
- post_it: function() {
- // create message and attempt to post it
- this.errors = new Array();
- document.post_form.message.value = document.post_form.subject.value = '';
- var _sub = document.getElementById('0').value;
- _fields[0][5] = true;
- document.post_form.subject.value = _sub;
- for(_f=0; _f<_fields.length; _f++) {
- if(document.getElementById(_f)) {
- _value = document.getElementById(_f).value;
- if(!_value || _value.match(/^s*$/)) {
- if(_f > 0 && _fields[_f][5])
- this.show_error('You have left the ' + _fields[_f][1] + ' option empty. This is a required field and as such must contain a value.');
- else
- _value = '[i]None[/i]';
- }
- document.post_form.message.value += '[b]' + _fields[_f][1] + ':[/b] ' + _value + '\n\n';
- }
- }
- if(this.errors.length == 0)
- document.post_form.post.click();
- else
- this.show_error();
- },
-
- show_error: function() {
- if("undefined" != typeof arguments[0] && arguments[0]) {
- this.errors.push(arguments[0]);
- } else {
- // Show Errors
- if(document.getElementById('status_holder')) {
- document.getElementById('status_holder_title').innerHTML = "An Error Has Occured";
- document.getElementById('status_holder_message').innerHTML = this.errors.join("<br />");
- document.getElementById('status_holder').style.display = 'block';
- }
- }
- }
- }
-
-
-
- if(document.post_form && location.href.match(/action\/post\/?$/) && vf_username != 'Guest') {
- _posting_form.init();
- }
- //-->
- </script>
| |
| Michael Moderator
    
![[Avatar]](http://av.wservices.co.uk/av.png) Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
  
pmvForum | Re: Code not working! (17th Dec 09 at 3:09am UTC) | | Again, you have the same error! | |
| Nick Very Senior Member
    
![[Avatar]](http://uploads.vforums.co.uk/forums/support/f_5e7b1402b305d883af97446b2fedc6c2_1-eog.jpeg) Posts: 3,013 Status: Offline Gender: Male Location: vForums Age: 35 Joined:
pmwww | Re: Code not working! (17th Dec 09 at 3:27am UTC) | | I see how it is now. I have it behind the apostrophe instead of behind. like '\ instead of \'
It's working now! ^_^; | |
| Michael Moderator
    
![[Avatar]](http://av.wservices.co.uk/av.png) Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
  
pmvForum | Re: Code not working! (17th Dec 09 at 3:29am UTC) | | Yea. Glad it's working! | |
| Nick Very Senior Member
    
![[Avatar]](http://uploads.vforums.co.uk/forums/support/f_5e7b1402b305d883af97446b2fedc6c2_1-eog.jpeg) Posts: 3,013 Status: Offline Gender: Male Location: vForums Age: 35 Joined:
pmwww | Re: Code not working! (17th Dec 09 at 3:35am UTC) | | Thanks for your help! now we can get our RP forum up and running now! | |
| |
 |  |
|