Post by Peter on Jul 15, 2005 2:41:07 GMT -8
<script type="text/javascript">
<!--
// Created by PopThosePringles
// Disabled certain profile elements for a user
// Main footer
Array.prototype.in_array = function(){
if(this && this.length > 0 && arguments[0]){
for(a = 0; a < this.length; a ++){
if(this.toLowerCase() == arguments[0].toLowerCase()){
document.modifyForm[this].disabled = true;
}
}
}
}
function disableProfile(user){
if(document.modifyForm){
if(pb_username == user){
for(e = 0; e < document.modifyForm.elements.length; e ++){
if(arguments[1]){
switch(arguments[1].constructor){
case Array :
arguments[1].in_array(document.modifyForm.elements.item(e).name);
break;
case String :
if(document.modifyForm[arguments[1]]){
document.modifyForm[arguments[1]].disabled = true;
break;
}
break;
}
}
}
}
}
}
disableProfile("admin", ["name", "sex", "websitename", "websiteurl"]);
//-->
</script>
When you want to disabled a certain users profile form elements, just add another line like so...
disableProfile("USERNAME", STRING or ARRAY)
For the STRING or ARRAY....
STRING would be if you want to just disable 1 profile element for that user...
disableProfile("admin", "name");
That would disable the admin's display name field, so he/she wouldn't be able to change the display name.
If you were wanting to disable more then one, you would then use an array like this....
disableProfile("USERNAME", ["ELEM1", "ELEM2", "ELEM3"]);
I've left the admin one in so you can see how it is done.
If you aren't sure what the names are of the form elements, just browser in the source. The name would be something that looks like....
<input type="text" name="email" />
<select name="sex">
etc
<!--
// Created by PopThosePringles
// Disabled certain profile elements for a user
// Main footer
Array.prototype.in_array = function(){
if(this && this.length > 0 && arguments[0]){
for(a = 0; a < this.length; a ++){
if(this.toLowerCase() == arguments[0].toLowerCase()){
document.modifyForm[this].disabled = true;
}
}
}
}
function disableProfile(user){
if(document.modifyForm){
if(pb_username == user){
for(e = 0; e < document.modifyForm.elements.length; e ++){
if(arguments[1]){
switch(arguments[1].constructor){
case Array :
arguments[1].in_array(document.modifyForm.elements.item(e).name);
break;
case String :
if(document.modifyForm[arguments[1]]){
document.modifyForm[arguments[1]].disabled = true;
break;
}
break;
}
}
}
}
}
}
disableProfile("admin", ["name", "sex", "websitename", "websiteurl"]);
//-->
</script>
When you want to disabled a certain users profile form elements, just add another line like so...
disableProfile("USERNAME", STRING or ARRAY)
For the STRING or ARRAY....
STRING would be if you want to just disable 1 profile element for that user...
disableProfile("admin", "name");
That would disable the admin's display name field, so he/she wouldn't be able to change the display name.
If you were wanting to disable more then one, you would then use an array like this....
disableProfile("USERNAME", ["ELEM1", "ELEM2", "ELEM3"]);
I've left the admin one in so you can see how it is done.
If you aren't sure what the names are of the form elements, just browser in the source. The name would be something that looks like....
<input type="text" name="email" />
<select name="sex">
etc