Post by Schubaltz on Apr 18, 2007 18:52:35 GMT -5
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>
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>