|
Post by rhondairv on Jun 8, 2010 11:49:51 GMT -8
I am curious if you can redo this a little so instead of the options i would fill in for the users, there is also an option for the user to fill in their own answers themselves.
So for example ... What is your player screen name?
They should be able to type in that.
I like the ability to give them options to pick from and would like to keep that, but also to be able to fill in their own answer.
Description: Creates additional fields as drop-down boxes selectable on the profile page (removes location field).
Source: Open
Cross-browser: Yes
Global Footer
<script type="text/javascript"> <!-- // Additional Options in Profile
var ops = [ [ "Field Name", "Field Description", "Option 1", "Option 2", "Option 3", "Option 4", "Option 5" ], [ "Field Name", "Field Description", "Option 1", "Option 2", "Option 3", "Option 4", "Option 5" ] // Repeat the above pattern for more fields ], exn = [], pre = []; if(location.href.match(/action=((pm)?view|display)/)) for(var l = document.links, k = 4; k < l.length; k ++) if(l[k].className == "nav") { for(var i = l[k].parentNode.getElementsByTagName("table")[1].rows, x = 1; x < i.length; x ++) { if(i[x].cells[0].className == "titlebg") break; if(i[x].cells[0].className == "catbg" || !i[x].cells[0].getElementsByTagName("b")[0]) continue; if(location.href.match(/viewprofile/)) for(var t = i[x].cells[1].getElementsByTagName("table")[0].rows, r = 4; r < t.length; r ++) if(t[r].innerHTML.match(/location:/i)) { t[r].style.display = "none"; break; } if(i[x].cells[0].innerHTML.match(/location: /i)) { pre = i[x].cells[0].innerHTML.split("Location: ")[1].split("<")[0] for(var e = 0; e < pre.split("%").length; e ++) if(pre.split("%")[e] != "0") exn.push(ops[e][0] + ": " + ops[e][pre.split("%")[e] - -1]); i[x].cells[0].innerHTML = i[x].cells[0].innerHTML.replace(/Location: \d+(%?\d+){0,}/, exn.join("<br />")); exn = []; } } break; } if(document.modifyForm) { var tables = document.modifyForm.getElementsByTagName("tbody"); tables[1].rows[1].style.display = "none"; for(var x in ops) { pre[x] = (document.modifyForm.location.value.split("%")[x] - 1) + 1 || 0; var row = tables[1].insertBefore(tables[1].rows[0].cloneNode(true), tables[1].rows[4 - -x]); row.cells[0].firstChild.firstChild.data = ops[x][0] + ":"; row.cells[2].firstChild.firstChild.data = ops[x][1]; var obj = document.createElement("select"); obj.name = x; obj[0] = new Option("-----"); for(var e = 2; e < ops[x].length; e ++) obj[e - 1] = new Option(ops[x][e]); obj.selectedIndex = pre[x]; obj.onchange = new Function("pre[this.name] = this.selectedIndex"); row.cells[1].firstChild.replaceChild(obj, row.cells[1].firstChild.firstChild); } document.modifyForm.onsubmit = new Function("document.modifyForm.location.value = pre.join('%')"); } //--> </script> [wayd:2:]
|
|
|
Post by Wormopolis on Jun 8, 2010 15:45:43 GMT -8
How many options are you looking to add?
|
|
|
Post by rhondairv on Jun 8, 2010 17:35:46 GMT -8
Just a few, 3 at the most so they mini profile does not get over loaded.
|
|
|
Post by Wormopolis on Jun 8, 2010 18:22:34 GMT -8
ok so I might need to explain how that code you posted works... (where did it come from I should ask as well, since it has no author credit)
it has defined arrays with predefined choices stored in it. when a user selects one of the choices, it only remembers the index of their choice from the array. you could drive someone bonkers if you changed the order the choices were in the array AFTER they made their choices because it would show on their miniprofile they had made a different choice then they did. the caveat is that what is stored in the "location" field is something like:
%1%3%2
which for my example would mean there was 3 drop downs they chose from, and they chose item 1, item 3, and item 2 respectively from the drop down for their choices.
now, in order to store something CUSTOM, it wouldnt be able to store JUST a number then. it would have to store the user's ENTIRE text choice. so lets say that we made this edit, and they wanted something custom for the second drop down, and it was an answer to the question "What type of food do you like?". they wanted to put "Anything that isnt mexican" as their custom answer. the location field would now have to store:
%1%Anything that isn't Mexican%2
see where I am going with this? the more they enter in as a custom answer, the more room it will take up in the location field. Im not sure what the max number of characters can be stored in the location field.. my guess would be similar to personal text which stores 128 chars I think. the other interesitng thing about that code, is it deletes anything the member tries to put into the location field and stores its own stuff there instead. effectively you will lose the ability to put a location (though you may be okay with that).
I also notice this code has a destructive call to the form submit function. that means that if this code were to run after ANY code that already does something with the submit function (inlcuding the second avatar code I just wrote for you) then those codes will no longer work because THIS code will overwrite the event handlers that they already latched on to. now this doesnt mean it cant play along, but it DOES mean that this code would have to run BEFORE any other code that affects profile information where the submit function has something else tacked on to it.
now with all that in mind, we can still make this happen, but if users get crazy and enter in way too much for an answer, the code will fail and possible keep the form from being submitted. You could probably get away with a FEW new added options, but every option that you allow them the ability to add their own answer that COULD be long, increases the risk.
That was my disclaimer... shall we proceed?
|
|
|
Post by rhondairv on Jun 8, 2010 19:51:33 GMT -8
It came from here forum.sz-ex.com/index.cgi?board=codes&action=display&thread=1687That is a lot to think about. Really all i wanted was a place they could add their screen name and how many awards they have from a game. I don't know if that is worth all the trouble of the code you'd have to write. How about we put this on hold for now because it sounds very complicated and if it messed up a bunch of other things it just would not be worth it. Thanks for taking the time to explain all that.
|
|
|
Post by Wormopolis on Jun 8, 2010 21:07:50 GMT -8
Oh no.. It most likely wouldnt be a LOT of work to do, I just wanted you to know there will be possible issues with the code if you use it. issues that wont be able to be solved.
|
|
|
Post by rhondairv on Jun 8, 2010 23:07:18 GMT -8
Well i like my 2nd avatar more than this. Let's just shelve this baby.
|
|