Click to See Complete Forum and Search --> : Replace Character


fshea31
09-04-2003, 09:20 AM
Hello. I recently received help on this forum with toggling between an empty space and a bullet in the paragraph tags of the cells of a table column. This is the answer I got, and it worked perfectly:

function SwapContents(e) {
if(navigator.userAgent.indexOf("MSIE")!=-1) {
if(event.srcElement.tagName=="P" && event.srcElement.cellIndex==4) {
event.srcElement.innerHTML=(event.srcElement.innerHTML==" ")? " • " : " ";
}
}
else {
if (e.target == "[object HTMLTableCellElement]" && e.target.cellIndex==4) {
e.target.innerHTML=(e.target.innerHTML==" ")? " • " : " ";
}
}
}

<table onclick="SwapContents(event);" etc. >

Now, all I need is a button (located in another frame) to clear whatever bullets have been "activated." In other words, just swap all at once the bullets back to the spaces. Thank you.

zachzach
09-14-2003, 04:08 PM
n=1
function SwapContents(e) {
if(n==1) {
if(navigator.userAgent.indexOf("MSIE")!=-1) {
if(event.srcElement.tagName=="P" && event.srcElement.cellIndex==4) {
event.srcElement.innerHTML=(event.srcElement.innerHTML==" ")? " • " : " ";
}
}
else {
if (e.target == "[object HTMLTableCellElement]" && e.target.cellIndex==4) {
e.target.innerHTML=(e.target.innerHTML==" ")? " • " : " ";
}
}
}

if(n!=1) {
if(navigator.userAgent.indexOf("MSIE")!=-1) {
if(event.srcElement.tagName=="P" && event.srcElement.cellIndex==4) {
event.srcElement.innerHTML=(event.srcElement.innerHTML==" ")? " " : " • ";
}
}
else {
if (e.target == "[object HTMLTableCellElement]" && e.target.cellIndex==4) {
e.target.innerHTML=(e.target.innerHTML==" ")? " " : " • ";
}
}
}

}

<table onclick="SwapContents(event); n++" etc. >