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.... (9th Sep 08 at 6:05pm UTC) Predefined form | | I have added extra lines but it seems as its not working! Whats wrong?
 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 = 'YGO: Duelists Realm Character Creation Form';
-
- var _description = '';
-
- var _fields = new Array(); var _f = 0;
- _fields[_f++] = new Array('input', 'Character name', ['size', 40, 'maxLength', 50], '', 'What is the name of your character?', false);
- _fields[_f++] = new Array('input', 'Age', ['size', 40, 'maxLength', 50], '', 'What is your characters age?', false);
- _fields[_f++] = new Array('input', 'Gender', ['size', 40, 'maxLength', 50], '', 'What is the gender of your character?', false);
- _fields[_f++] = new Array('input', 'Species', ['size', 40, 'maxLength', 250], '', 'What is your characters Species?.', false);
- _fields[_f++] = new Array('input', 'Good/Evil/Neutral', ['cols', 40, 'rows', 3], '', 'Please tell us if you are good, evil, or neutral.', false);
- _fields[_f++] = new Array('textarea', 'Appearance', ['size', 40, 'maxLength', 350], '', 'Please give a description of your characters appearence.', false);
- _fields[_f++] = new Array('textarea', 'Personality', ['cols', 40, 'rows', 4], '', 'What is your character personality like?.', false);
- _fields[_f++] = new Array('textarea', 'History', ['size', 40, 'maxLength', 350], '', 'Please tell us you characters history.', false);
- _fields[_f++] = new Array('textarea', 'Cards', ['size', 40, 'maxLength', 250], '', 'Please list your cards', false);
- _fields[_f++] = new Array('textarea', 'Hobbies', ['size', 40, 'maxLength', 250], '', 'What are your characters hobbies?', false);
- _fields[_f++] = new Array('textarea', 'Jobs', ['size', 40, 'maxLength', 250], '', 'What kind of job does your character do? IE: Duelist, Card seller, unemployed, etc.', false);
- _fields[_f++] = new Array('textarea', 'Example RP', ['size', 40, 'maxLength', 0], '', 'Follow the RP below', false);
- _fields[_f++] = new Array('input', 'Counter', ['size', 40, 'maxLength', 50], '', 'This Field is for when it is your turn after your opponents, this will be for counter attacks such as effect of spells, traps, and effect monsters', false);
- _fields[_f++] = new Array('input', 'Comments', ['size', 40, 'maxLength', 50], '', 'Pretend you are dueling someone and make a comment about their play', false);
- _fields[_f++] = new Array('input', 'Draw Phase', ['size', 40, 'maxLength', 50], '', 'This is your Draw Phase.', false);
- _fields[_f++] = new Array('input', 'Standby Phase', ['size', 40, 'maxLength', 50], '', 'This is your standby phase to look at your hand.', false);
- _fields[_f++] = new Array('input', 'Main Phase 1', ['size', 40, 'maxLength', 50], '', 'This is your main phase 1 to place a monster or trap/spell card', false);
- _fields[_f++] = new Array('input', 'Battle Phase', ['size', 40, 'maxLength', 50], '', 'This is the phase you attack your opponent's monsters or directly to LP.', false);
- _fields[_f++] = new Array('input', 'Main Phase 2', ['size', 40, 'maxLength', 50], '', 'This phase 2 is for laying down extra cards I.E. Traps or Spells.', false);
- _fields[_f++] = new Array('input', 'End Phase', ['size', 40, 'maxLength', 50], '', 'This is the end phase nothing you can do here only by saying "done".', 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>
| |
| 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.... (9th Sep 08 at 6:15pm UTC) | | Sorry for double post, tried to edit my first post and it said the post was to long.
This is not working either:
 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 = 'YGO: Duelists Realm Character Creation Form';
-
- var _description = '';
-
- var _fields = new Array(); var _f = 0;
-
- var _fields = new Array(); var _f = 0;
- _fields[_f++] = new Array('input', 'Counter', ['size', 40, 'maxLength', 50], '', 'This Field is for when it is your turn after your opponents. <br /> This will be for counter attacks such as effect of spells traps and effect monsters.', false);
- _fields[_f++] = new Array('input', 'Comments', ['size', 40, 'maxLength', 50], '', 'You will comment your opponents play here.', false);
- _fields[_f++] = new Array('input', 'Draw Phase', ['size', 40, 'maxLength', 50], '', 'This is your Draw Phase.', false);
- _fields[_f++] = new Array('input', 'Standby Phase', ['size', 40, 'maxLength', 50], '', 'This is your standby phase to look at your hand.', false);
- _fields[_f++] = new Array('input', 'Main Phase 1', ['size', 40, 'maxLength', 50], '', 'This is your main phase 1 to place a monster or trap/spell card', false);
- _fields[_f++] = new Array('input', 'Battle Phase', ['size', 40, 'maxLength', 50], '', 'This is the phase you attack your opponent's monsters or directly to LP.', false);
- _fields[_f++] = new Array('input', 'Main Phase 2', ['size', 40, 'maxLength', 50], '', 'This phase 2 is for laying down extra cards such as Traps or Spells.', false);
- _fields[_f++] = new Array('input', 'End Phase', ['size', 40, 'maxLength', 50], '', 'This is the end phase nothing you can do here only by saying done.', 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>
| |
| Ross Administrator
    
![[Avatar]](http://uploads.virtualforums.co.uk/forums/pokemon/vforums-qr1.png) Posts: 3,709 Status: Offline Gender: Male Age: 9 1⁄4 Joined:
Additional Groups: Support Team
  
pmwwwgtalkvForum | Re: Code not working.... (10th Sep 08 at 10:51pm UTC) | | This line has an unescaped apostrophe
_fields[_f++] = new Array('input', 'Battle Phase', ['size', 40, 'maxLength', 50], '', 'This is the phase you attack your opponent\'s monsters or directly to LP.', 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.... (10th Sep 08 at 11:06pm UTC) | | in both codes?
Ok it works
why do you need a backslash in 's for ? I do not understand that.
but for the first code in the field of "Example RP" I don't want a text field how can I get it to be a name for the Example Rp area?
Ok another thing is, is not for my forum, but for my site that is linked to my forum, this is the first time I have ever encountered this problem.
on my site when I click on Advertise it goes to a blank page, but when you back up the page is goes to the main forum page. I am not releasing the forum/site right now to view. But this is the code for it.
 Code: - <table border="0">
- <tr>
- <th>
- <p>.:Navigation:.</p>
- </th>
- </tr>
- <tr>
- <td><a href="http://ygodr.co.nr" target="_parent">Home</a></td>
- </tr>
- <tr>
- <td><a href="http://ygo.vforums.co.uk" target="_parent">Forum</a></td>
- </tr>
- <tr>
- <td><a href="http://ygo.vforums.co.uk/board/info/" target="_parent">Rules</a></td>
- </tr>
- <tr>
- <td><a href="http://ygodr-news.co.nr" target="_parent">News</a></td>
- </tr>
- <tr>
- <td><a href="http://ygo.vforums.co.uk/board/advertise/" target="_parent">Advertise</a></td>
- </tr>
- </table>
-
| |
| Ross Administrator
    
![[Avatar]](http://uploads.virtualforums.co.uk/forums/pokemon/vforums-qr1.png) Posts: 3,709 Status: Offline Gender: Male Age: 9 1⁄4 Joined:
Additional Groups: Support Team
  
pmwwwgtalkvForum | Re: Code not working.... (14th Sep 08 at 9:44pm UTC) | | in both codes?Ok it works why do you need a backslash in 's for ? I do not understand that.
That description is wrapped in 's, it's what tells the code where that description starts and ends. By having another ' within the text the code thinks that description has ended. The backslash basically tells the code to treat the ' as a standard apostrophe rather than as the end of the description.
Quote: but for the first code in the field of "Example RP" I don't want a text field how can I get it to be a name for the Example Rp area?
Do you mean you want it as just 1 line of text?
_fields[_f++] = new Array('input', 'Example RP', ['size', 40], '', 'Follow the RP below', false);
Quote: Ok another thing is, is not for my forum, but for my site that is linked to my forum, this is the first time I have ever encountered this problem.
on my site when I click on Advertise it goes to a blank page, but when you back up the page is goes to the main forum page. I am not releasing the forum/site right now to view. But this is the code for it.
I'm not entirely sure what you mean there? Unless you've already fixed it? | |
|
| |
 |  |
|