vForums Support :: Programming & Coding :: Database of Codes/Hacks/Mods :: Predefined Posting Template/Form - View Topic (Page 4 of 5)
| |
| Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Re: Predefined Posting Template/Form (18th Dec 09 at 8:26pm UTC) | | Ok your Room code works perfectly now and I will get on the second one. Don't change anything within the code, as it may mess it up again.
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 = 'Buying a room';
- var _description = 'Please fill out these fields to buy your room, it costs 1 gold and 5 silver.';
- var _fields = new Array(); var _f = 0;
-
- _fields[_f++] = new Array('input', 'Room Name', ['size', 40, 'maxLength', 50], 'New room', '', true);
- _fields[_f++] = new Array('select', 'Location of Room', false, ['Perfect World', '--Portal of Darkness', '--Paradise', '----Kami\'s battle house', '----Fantasia'], '..', true);
- _fields[_f++] = new Array('textarea', 'Brief Description', ['cols', 40, 'rows', 10, 'maxlength', 300], '', '300 characters max', true);
- _fields[_f++] = new Array('textarea', 'Full Description', ['cols', 40, 'rows', 10], '', 'Unlimited characters - optional', 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 = 'None';
- }
- document.post_form.message.value += '' + _fields[_f][1] + ': ' + _value + 'nn';
- }
- }
- 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>
| |
| Aiken Full Member
Posts: 333 Status: Offline Gender: Male Location: In a very lonely place, the domain of despair Age: 35 Joined:
pmskypemsnyahooxfire | | Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Re: Predefined Posting Template/Form (18th Dec 09 at 9:23pm UTC) | | I've got the other code right here, and what do you mean?
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 = 'Create a group';
- var _description = 'The cost to create a group is 50,000 Yen except for admin';
- var _fields = new Array(); var _f = 0;
-
- _fields[_f++] = new Array('input', 'Group Name', ['size', 40, 'maxLength', 20], '', ' ', true);
- _fields[_f++] = new Array('input', 'Your Group Rank', ['size', 40, 'maxLength', 15], '', ' ', true);
- _fields[_f++] = new Array('select', 'Your Group Rank Color', false, ['None', 'Red', 'Blue','Green','Orange','Purple','White','Pink','Gray','Gold','Silver'], '', true);
- _fields[_f++] = new Array('input', 'Starting Group Rank', ['size', 40, 'maxLength', 15], false, 'Optional', false);
- _fields[_f++] = new Array('select', 'Group Color', false, ['None', 'Red', 'Blue','Green','Orange','Purple','White','Pink','Gray','Gold','Silver'], '', true);
- _fields[_f++] = new Array('textarea', 'Brief Description', ['cols', 40, 'rows', 5, 'maxlength', 300], false, '300 character max', true);
- _fields[_f++] = new Array('textarea', 'Full Description', ['cols', 40, 'rows', 20], false, '', 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 = 'None';
- }
- document.post_form.message.value += '' + _fields[_f][1] + ': ' + _value + 'nn';
- }
- }
- 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>
| |
| Aiken Full Member
Posts: 333 Status: Offline Gender: Male Location: In a very lonely place, the domain of despair Age: 35 Joined:
pmskypemsnyahooxfire | | Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Re: Predefined Posting Template/Form (18th Dec 09 at 11:33pm UTC) | | Oh I see what you mean. Just follow this format:
_fields[_f++] = new Array('select', 'Location of Room', false, ['Perfect World', '--Portal of Darkness', '--Paradise', '----Kami\'s battle house', '----Fantasia','new room 1','new room 2'], '..', true);
just add ,'new room here' when you want a new room.
and if there is something like above "Kami's" you would want to add "Kami\'s", because without the back slash, it would break the code. | |
| Aiken Full Member
Posts: 333 Status: Offline Gender: Male Location: In a very lonely place, the domain of despair Age: 35 Joined:
pmskypemsnyahooxfire | | Aiken Full Member
Posts: 333 Status: Offline Gender: Male Location: In a very lonely place, the domain of despair Age: 35 Joined:
pmskypemsnyahooxfire | | Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Re: Predefined Posting Template/Form (19th Dec 09 at 10:47pm UTC) | | I just took the code from the first page, and added the "_fields[_f++]" part, and it works just fine. I tried those parts with the 1 you had it didn't work, but it worked quite well with the first one on the first page. I'm still a newbie to coding. But I do know allot of it. | |
| Aiken Full Member
Posts: 333 Status: Offline Gender: Male Location: In a very lonely place, the domain of despair Age: 35 Joined:
pmskypemsnyahooxfire | | Aiken Full Member
Posts: 333 Status: Offline Gender: Male Location: In a very lonely place, the domain of despair Age: 35 Joined:
pmskypemsnyahooxfire | | Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Re: Predefined Posting Template/Form (23rd Dec 09 at 5:17am UTC) | | I'm not sure how to do that. PM Micheal and he could do it for you. | |
| Michael Moderator
Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
pmvForum | Re: Predefined Posting Template/Form (23rd Dec 09 at 2:38pm UTC) | | I don't see what you'd need check boxes or radio buttons for that a select box couldn't do. =/ | |
| Aiken Full Member
Posts: 333 Status: Offline Gender: Male Location: In a very lonely place, the domain of despair Age: 35 Joined:
pmskypemsnyahooxfire | Re: Predefined Posting Template/Form (23rd Dec 09 at 7:40pm UTC) | | There are things where radio buttons and checkboxes would be better than select box,
Example 1: Gender - Best as radio buttons
Example 2: Multiple options that can be selected: checkboxes
I know how to do this with select box but checkboxes would just be easier on the user end | |
vF forums: Perfect World RP BLEACH Universe - Under Construction / Testing Phase Xen Qarna RP - Stage I Vyren Entar Battle Network RP - Under Construction / Maintenance Mode Enabled the Final Anime Hideout |
| Michael Moderator
Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
pmvForum | Re: Predefined Posting Template/Form (24th Dec 09 at 6:12am UTC) | | Gender, in my opinion would be best as a select box.
Anyway, I'm heading away for Christmas in 2 hours, so got to pack etc. I won't be able to get to this until after .... unless someone else jumps on it. | |
| Aiken Full Member
Posts: 333 Status: Offline Gender: Male Location: In a very lonely place, the domain of despair Age: 35 Joined:
pmskypemsnyahooxfire | | |
| |
|