Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Mithras

Mithras Avatar

****
Studio Member

600


July 2006
Hey, I was trying to do this code for someone over at PBS, and it's not working :P

Here it is:


<script type="text/javascript">
var fieldName = "Field";
var fieldSize = 15;
var fieldDescription = "My Field";

if(location.href.match(/action=modifyprofile/i)) {
var sigTable = document.modifyForm.signature.parentNode.parentNode.parentNode.parentNode;
var newLine = sigTable.insertRow(-1);

var newCell1 = newLine.insertCell(0);
var newCell2 = newLine.insertCell(1);
var newCell3 = newLine.insertCell(2);

newCell1.innerHTML = '<font size=2>' + fieldName + '</font>';
newCell2.innerHTML = '<input type="text" size="35" maxlength="' + fieldSize + '" name="fieldInput">';
newCell3.innerHTML = '<font size="1">' + fieldDescription + '</font>';

var field = RegExp.$1

document.modifyForm.fieldInput.value = group;

document.modifyForm.personaltext.value = document.modifyForm.personaltext.value.replace('-field='+field+'-','');
}

function addClass() {
document.modifyForm.personaltext.maxLength="100";

document.modifyForm.personaltext.value += document.modifyForm.elem.value;

document.modifyForm.submit();

document.modifyForm.onsubmit = addClass();
}

var allRows = document.getElementsByTagName('td');

for(i=0; i<allRows.length; i++) {
if(allRows.innerHTML.match(/\-field=(.+?)\-/i) && TD[t].width=="20%"){
var group = RegExp.$1;

var replace = allRows.innerHTML.replace('-field='+group+'-','');

allRows.innerHTML = replace;

allRows.innerHTML+="<br/>" + fieldName + ": " + field;
}
}
//-->
</script>


I got it to add the modify area in the profile, but I can't get it to come up in the miniprofile :-/

Any help would be appreciated.



Support Rob Scuderi, the #1 Penguins Defender!

lucifer said:
"Behold: me! I have authority in this building."

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
document.modifyForm.fieldInput.value = group;
Where do you define "group"?


document.modifyForm.onsubmit = addClass();
That's inside the "addClass" function for starters. Next, there's two ways to do this. You mixed 'em.

document.modifyForm.onsubmit = addClass;

OR

document.modifyForm.onsubmit = function(){ addClass(); }



Try fixing those first.

Mithras

Mithras Avatar

****
Studio Member

600


July 2006
Hmm... I fixed them, but it's still not working. Here's what I have now:


<script type="text/javascript">
var fieldName = "Field";
var fieldSize = 15;
var fieldDescription = "My Field";

if(location.href.match(/action=modifyprofile/i)) {
var sigTable = document.modifyForm.signature.parentNode.parentNode.parentNode.parentNode;
var newLine = sigTable.insertRow(-1);

var newCell1 = newLine.insertCell(0);
var newCell2 = newLine.insertCell(1);
var newCell3 = newLine.insertCell(2);

newCell1.innerHTML = '<font size=2>' + fieldName + '</font>';
newCell2.innerHTML = '<input type="text" size="35" maxlength="' + fieldSize + '" name="fieldInput">';
newCell3.innerHTML = '<font size="1">' + fieldDescription + '</font>';

var field = RegExp.$1

document.modifyForm.fieldInput.value = field;

document.modifyForm.personaltext.value = document.modifyForm.personaltext.value.replace('-field='+field+'-','');
}

function addClass() {
document.modifyForm.personaltext.maxLength="100";

document.modifyForm.personaltext.value += document.modifyForm.elem.value;

document.modifyForm.submit();

}

document.modifyForm.onsubmit = addClass;

var allRows = document.getElementsByTagName('td');

for(i=0; i<allRows.length; i++) {
if(allRows.innerHTML.match(/\-field=(.+?)\-/i) && TD[t].width=="20%"){
var group = RegExp.$1;

var replace = allRows.innerHTML.replace('-field='+group+'-','');

allRows.innerHTML = replace;

allRows.innerHTML+="<br/>" + fieldName + ": " + field;
}
}
//-->
</script>



Support Rob Scuderi, the #1 Penguins Defender!

lucifer said:
"Behold: me! I have authority in this building."

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
for(i=0; i<allRows.length; i++) {
if(allRows[i].innerHTML.match(/\-field=(.+?)\-/i) && TD[t].width=="20%"){


You use TD and t, yet its defined as allRows and i.

for(i=0; i<allRows.length; i++) {
if(allRows[i].width=="20%" && allRows[i].innerHTML.match(/\-field=(.+?)\-/i)){


That should work. Also, always check innerHTML last.

newBookmarkLockedFalling