onmouseover calling event on table column activated from another

Basically, when I put the mouse over 'link', i want 'about' to be shown or hidden. I am nrealy there, but it doesnt appear to work. I know this is v bad code but a few tips would be v much appreciated :)

TABLE WIDTH="100%">
<SCRIPT LANGUAGE="JavaScript">

{var b}

function PrtRow(name, about) {
newcol = "</TD><TD ALIGN='LEFT'>";
{size = "<font size=\"4\">"}
{var cfd}
{var bool}
{var hold}
{var twenty47}
{cfd = LinkName(name);}
{hold = b;}
{twenty47 = procBool(b);}

{link = "<a href=\"http://www.xxx/xxx/xxx/support/" + cfd + "onMouseOver=\"showText()\" onMouseOut=\"hideText()\";>"}
document.write(" <TR> <TD WIDTH=\"40%\"> ", link, size , name, twenty47 ,"</font>", "</a>" , newcol,"<div id=\"theInvisText\" style=\"display:none;\">", about,"</div>", newcol, "</TD></TR>\n")

}


function showText()
{
{document.getElementById("theInvisText").style.display="block"};
}


function hideText()
{
document.getElementById("theInvisText").style.display="none"};

}





PrtRow("Cantos ","");

function procBool(c)
{
if (c == true)
{ c = "<font color=\"#FF0000\"><b><span style=\"font-size: 10.0pt; font-family: Arial; background-color: #FFFF00\">24x7</span></b></font>";
return c;
}
else if (c == false)
{ c = "";
return c;
}
}



function LinkName(a)
{
if (a == "Cantos " )
{ a = "supported_applications.asp\"";
b = false;
return a;
}
[1786 byte] By [pixelgirl] at [2007-11-20 2:17:29]
# 1 Re: onmouseover calling event on table column activated from another
Basically, when I put the mouse over 'link', i want 'about' to be shown or hidden.
Are you talking about a little hover such as the alt does for images?

First off, don't put {} around variables. They only envelope functions, statements, and loops. Your code is very hard is very confusing. I cleaned it up a little but I still don't get exactly what you are trying to do.
<SCRIPT LANGUAGE="JavaScript">
var b;

function PrtRow(name, about) {
newcol = "</TD><TD ALIGN='LEFT'>";
size = "<font size=\"4\">";
var cfd;
var bool;
var hold;
var twenty47;
cfd = LinkName(name);
hold = b;
twenty47 = procBool(b);

link = "<a href=\"http://www.xxx/xxx/xxx/support/" + cfd + "onMouseOver=\"showText()\" onMouseOut=\"hideText()\";>"}
document.write(" <TR> <TD WIDTH=\"40%\"> ", link, size , name, twenty47 ,"</font>", "</a>" , newcol,"<div id=\"theInvisText\" style=\"display:none;\">", about,"</div>", newcol, "</TD></TR>\n")


function showText(){
document.getElementById("theInvisText").style.display="block"};
}


function hideText(){
document.getElementById("theInvisText").style.display="none"};
}

PrtRow("Cantos ","");

function procBool(c){
if(c == true){
c = "<font color=\"#FF0000\"><b><span style=\"font-size: 10.0pt; font-family: Arial; background-color: #FFFF00\">24x7</span></b></font>";
return c;
}
else if(c == false){
c = "";
return c;
}
}

function LinkName(a){
if(a == "Cantos "){
a = "supported_applications.asp\"";
b = false;
return a;
}
}
PeejAvery at 2007-11-8 0:41:09 >
# 2 Re: onmouseover calling event on table column activated from another
Thanks for the advice, i am not the best coder in the world (probably not the worst but i think its a close one) basically the code

document.write(" <TR> <TD WIDTH=\"40%\"> ", link, size , name, twenty47 ,"</font>", "</a>" , newcol,"<div id=\"theInvisText\" style=\"display:none;\">", about,"</div>", newcol, "</TD></TR>\n"

generates a table with a list of names in the first column (the first one being cantos - too many others to put in so i left the others out)

I know the codes horrendous, but i didnt write it myself - age old excuse i kno but it kind of did what i wanted - and when you put the mouse over a name in the first column, a description in the second column appears (basically make it white or black, or using css? appear or not . I can use the onmouseover event to call a function, but then dont ereally know what to put in it :

function showText(){
document.getElementById("theInvisText").style.display="block"};
}

this should show the text in the second column then when mouse goes off the text it disappears, not like a bubble thing but just is shown or hidden in its column.

Thanks for the help :)
pixelgirl at 2007-11-8 0:42:09 >
# 3 Re: onmouseover calling event on table column activated from another
Okay, I thought of some other suggestions for you.

1. Always have functions defined before they are called. For example, you have LinkName() and procBool() at the bottom. Notice that they are called when you execute PrtRow("Cantos ","") which is before them. That means you will get an error saying that the functions are undefined or unknown.

2. document.write uses + (plus) not , (comma).

3. If your table has more than 1 row, which I am sure that it does, that means that each div will have the same id (theInvisText). So when you call it, you won't get the one you want.
PeejAvery at 2007-11-8 0:43:16 >
# 4 Re: onmouseover calling event on table column activated from another
Yep, it does have 2 rows, i didnt realise both would take the same id :(
thanks for the advice about calling function, i can never remember if they go before they are called or after - though i have to say when running this online everything works perfectly except the bit to change the colour onmouseover.
Someone said they saw something similar recently but cant remember where otherwise I would have 'borrowed' the code :), but i basically hobbled this together myself, and its not very good (understatement i kno) but it does work for everything except this issue.

Could you think of another way completly to do this, would it be better to just write out all the code for the table?

Thanks.
pixelgirl at 2007-11-8 0:44:16 >
# 5 Re: onmouseover calling event on table column activated from another
To change the color give the TD an ID as well.

onmouseover=\"document.getElementById(TD_ID).style.background='#HEXCOLOR'\"
onmouseout=\"document.getElementById(TD_ID).style.background='#HEXCOLOR'\"
PeejAvery at 2007-11-8 0:45:14 >
# 6 Re: onmouseover calling event on table column activated from another
right - see attachement for what it looks like - when you put your mouse over the name 'cantos' etc text shoud 'appear' in the next column.
I have changed it round as you said but im not sure about where to put the td id - in the onmouseover but, the function or next to 'about'?

Thanks.
pixelgirl at 2007-11-8 0:46:13 >
# 7 Re: onmouseover calling event on table column activated from another
p.s. i moved all the code round as you said and now it doesnt work ;) lol.
pixelgirl at 2007-11-8 0:47:20 >
# 8 Re: onmouseover calling event on table column activated from another
ah no, its ok its working, but still not the onmouseover.
pixelgirl at 2007-11-8 0:48:18 >
# 9 Re: onmouseover calling event on table column activated from another
The ID would go in the TD tag.

<td id="whatever">
PeejAvery at 2007-11-8 0:49:16 >
# 10 Re: onmouseover calling event on table column activated from another
but surely that will change the colour of the whole of the table rather than just one of the columns?
pixelgirl at 2007-11-8 0:50:25 >
# 11 Re: onmouseover calling event on table column activated from another
but surely that will change the colour of the whole of the table rather than just one of the columns?
No. The ID is in the TD, not the TABLE tag. This means you will only affect the TD.
PeejAvery at 2007-11-8 0:51:23 >
# 12 Re: onmouseover calling event on table column activated from another
right, my code is still not working:

else
{ a = "supported_applications.asp\"";
b = false;
return a;
}

}

function PrtRow(name, about) {

function showText()
{
{document.getElementById("theInvisText").style.display="block"};
}

function hideText()
{
{document.getElementById("theInvisText").style.display="none"};

}

newcol = "</TD><TD Id=\"theInvisText\" ALIGN='LEFT'>";
size = "<font size=\"4\">"
var cfd
var bool
var hold
var twenty47
cfd = LinkName(name);
hold = b;
twenty47 = procBool(b);

link = "<a href=\"http://www.xxxxxxxx.com/xxx/xxx/support/" + cfd + "onMouseOver=\"showText()\" onMouseOut=\"hideText()\";>"
document.write(" <TR> <TD WIDTH=\"40%\"> " + link + size + name + twenty47 +"</font>" + "</a>" + newcol + "<div style=\"display:none;\">" + about + "</div>" + "</TD></TR>\n")

}


PrtRow("Cantos ","hello");
pixelgirl at 2007-11-8 0:52:24 >
# 13 Re: onmouseover calling event on table column activated from another
Since I do not have the same table output, it would be very beneficial to you to download Firefox, execute the page and look at the Error Console. That is an amazing scripting debugger.
PeejAvery at 2007-11-8 0:53:21 >
# 14 Re: onmouseover calling event on table column activated from another
great - i have it at home - how do i get the error console? does it appear automatically or is it in one of the menus?
Thanks for all the help :)

also - my issue seems similar to this one by Stin :
http://www.dev-archive.com/forum/showthread.php?t=401549
any idea how it was solved?
pixelgirl at 2007-11-8 0:54:21 >
# 15 Re: onmouseover calling event on table column activated from another
stin didn't say what part was wrong but it was a typo in his coding somewhere. He did not say where.

The Error console is located under the Tools menu. I would suggest downloading Firefox 2 RC3. It is very stable and I love it. (At least when I am on a PC and not using my Mac)
PeejAvery at 2007-11-8 0:55:25 >
# 16 Re: onmouseover calling event on table column activated from another
Right - its now (nearly) completely working :) though I have one more question -

i can get it to show/hide the text in the right hand column for the first entry in the table, but for any row after the first it does not work - can you tell me how exactly the id works in the DIV tag - I would've thought that it gives the same id to every row defined, but it appears that it only gives it to the first?

PeejAvery - thanks for the tip of firefox debugger - it turned out the show/hide text functions werent defined as I had put {} round code inside the function :S, much appreciated :)

function showText()
{
document.getElementById("theInvisText").style.visibility ="visible";
}

function hideText()
{
document.getElementById("theInvisText").style.visibility="hidden";

}

function PrtRow(name, about) {

newcol = "</TD><TD ALIGN='LEFT'>";
size = "<font size=\"4\">";
var cfd
var bool
var hold
var twenty47
cfd = LinkName(name);
hold = b;
twenty47 = procBool(b);

link = "<a href=\"http://www.xxxxxxxx.com/xxx/xxxx/support/" + cfd + "onMouseOver=\"showText()\" onMouseOut=\"hideText()\";>"
document.write(" <TR> <TD WIDTH=\"40%\"> " + link + size + name + twenty47 +"</font>" + "</a>" + newcol + "<DIV id=\"theInvisText\" style=\"visibility:hidden;\">" + about + "</div>" + "</TD></TR>\n")

}


PrtRow("Cantos ","hello");
PrtRow("etc ","etc");
PrtRow("etc ","etc");
pixelgirl at 2007-11-8 0:56:26 >
# 17 Re: onmouseover calling event on table column activated from another
i can get it to show/hide the text in the right hand column for the first entry in the table, but for any row after the first it does not work - can you tell me how exactly the id works in the DIV tag - I would've thought that it gives the same id to every row defined, but it appears that it only gives it to the first?
Do all the DIVs have the same ID?

Try the following.
1. Create an integer outside of whatever loop you have.
var divInt = 0;
2. Make the DIV id have that integer.
<div id='div" + divInt + "'></div>
3. Increment the variable.
divInt++;
Now, each of your divs will be div1, div2, div3...
PeejAvery at 2007-11-8 0:57:29 >
# 18 Re: onmouseover calling event on table column activated from another
great - very nifty - i was trying to give each an individual name :)
pixelgirl at 2007-11-8 0:58:23 >
# 19 Re: onmouseover calling event on table column activated from another
great - very nifty - i was trying to give each an individual name :)
That can get tedious really fast. Glad to be of help.
PeejAvery at 2007-11-8 0:59:34 >
# 20 Re: onmouseover calling event on table column activated from another
doh - it is not working and i cant seem to see what is wrong?! There is nothing on the javascript error console - plz take a look and see if you can spot it? the first id is still brought up like last time - so i dont know if theres something wrong with the loop? - my coding is v rusty :)

** the var divInt is declared further up in the code.

function showText()
{
document.getElementById("theInvisText" + divInt + "").style.visibility ="visible";
}

function hideText()
{
document.getElementById("theInvisText" + divInt + "").style.visibility="hidden";

}

function PrtRow(name, about) {

var x
for (x=1;x<=48;x++)
{
divInt = x;
}

newcol = "</TD><TD ALIGN='LEFT'>";
size = "<font size=\"4\">";
var cfd
var bool
var hold
var twenty47
cfd = LinkName(name);
hold = b;
twenty47 = procBool(b);

link = "<a href=\"http://www.xxxxxxxx.com/xxx/xxx/support/" + cfd + "onMouseOver=\"showText()\" onMouseOut=\"hideText()\";>"
document.write(" <TR> <TD WIDTH=\"40%\"> " + link + size + name + twenty47 +"</font>" + "</a>" + newcol + "<DIV id='theInvisText" + divInt + "' style=\"visibility:hidden;\">" + about + "</div>" + "</TD></TR>\n")

}


PrtRow("Cantos ","hello");

edit ** for some reason my loop outputs the last number (48) on the first line :( i have no idea whats happening now??
pixelgirl at 2007-11-8 1:00:30 >
# 21 Re: onmouseover calling event on table column activated from another
edit ** for some reason my loop outputs the last number (48) on the first line :( i have no idea whats happening now??
That is because you have the loop set do run through. Notice, you call the function, and right away the loop makes divInt = 1,2,3,4...48. Try the following.

var divInt = 0;
function PrtRow(name, about) {
divInt++;

newcol = "</TD><TD ALIGN='LEFT'>";
size = "<font size=\"4\">";
var cfd
var bool
var hold
var twenty47
cfd = LinkName(name);
hold = b;
twenty47 = procBool(b);

link = "<a href=\"http://www.xxxxxxxx.com/xxx/xxx/support/" + cfd + "onMouseOver=\"showText()\" onMouseOut=\"hideText()\";>"
document.write(" <TR> <TD WIDTH=\"40%\"> " + link + size + name + twenty47 +"</font>" + "</a>" + newcol + "<DIV id='theInvisText" + divInt + "' style=\"visibility:hidden;\">" + about + "</div>" + "</TD></TR>\n")

}
PeejAvery at 2007-11-8 1:01:34 >
# 22 Re: onmouseover calling event on table column activated from another
That works perfectly, I was being an idiot not realising that its called each time(!)

one more question :) :
r.e my code below - in the show and hide text functions, what do i put in the getElementById(...) bit - i know i can put in text, but will it work if i put "theInvisText" + divId, as im not sure if the loop would change the divId bit, even though its declared outside the function. Its triggered dynamicy isnt it, so the incrementing of the numbers in the function below wouldnt give it the correct number? How would i get this to work? I have tried it this way but nothing happens. Could i somehow get the function to call the correct ID another way?
Thanks for all the help so far :>

function showText()
{
document.getElementById(...).style.visibility ="visible";
}

function hideText()
{
document.getElementById(...).style.visibility="hidden";
}

function PrtRow(name, about)
{
divInt++;
newcol = "</TD><TD ALIGN='LEFT'>";
size = "<font size=\"4\">";
var cfd
var bool
var hold
var twenty47
cfd = LinkName(name);
hold = b;
twenty47 = procBool(b);

link = "<a href=\"http://www..xxxxxx.com/xxx/xxx/support/" + cfd + "onMouseOver=\"showText()\" onMouseOut=\"hideText()\";>"
document.write(" <TR> <TD WIDTH=\"40%\"> " + link + size + name + twenty47 +"</font>" + "</a>" + newcol + "<DIV id=\"theInvisText" + divInt + "\" style=\"visibility:visible;\">" + about + "</div>" + "</TD></TR>\n")

}


PrtRow("Cantos ","hello");
pixelgirl at 2007-11-8 1:02:35 >
# 23 Re: onmouseover calling event on table column activated from another
Please remember to use [code] tags. Use a function variable like so...

function showText(whichdiv){
document.getElementById(whichdiv).style.visibility ="visible";
}

function hideText(whichdiv){
document.getElementById(whichdiv).style.visibility="hidden";
}

function PrtRow(name, about){
divInt++;
newcol = "</TD><TD ALIGN='LEFT'>";
size = "<font size=\"4\">";
var cfd
var bool
var hold
var twenty47
cfd = LinkName(name);
hold = b;
twenty47 = procBool(b);

link = "<a href=\"http://www..xxxxxx.com/xxx/xxx/support/" + cfd + "onMouseOver=\"showText('theInvisText" + divInt + "')\" onMouseOut=\"hideText('theInvisText" + divInt + "')\";>"
document.write(" <TR> <TD WIDTH=\"40%\"> " + link + size + name + twenty47 +"</font>" + "</a>" + newcol + "<DIV id=\"theInvisText" + divInt + "\" style=\"visibility:visible;\">" + about + "</div>" + "</TD></TR>\n")

}

PrtRow("Cantos ","hello");
PeejAvery at 2007-11-8 1:03:30 >
# 24 Re: onmouseover calling event on table column activated from another
nope - doesnt appear to be working - what does whichdiv do? i have not heard of it before and a quick search on google only brings up a few examples with no explanation - as the div id is on the second column of the table does this matter?
shall i give the first column in the table the same div ids as well?
Thanks.

edit - the javascript console says:

Error: document.getElementById(whichdiv) has no properties

i have no idea about this?
pixelgirl at 2007-11-8 1:04:36 >
# 25 Re: onmouseover calling event on table column activated from another
Error: document.getElementById(whichdiv) has no properties
That means that the following line is setup wrong.
link = "<a href=\"http://www..xxxxxx.com/xxx/xxx/support/" + cfd + "onMouseOver=\"showText('theInvisText" + divInt + "')\" onMouseOut=\"hideText('theInvisText" + divInt + "')\";>"
Put the following in the function and see what div id it is trying to call.
alert(whichdiv);
whichdiv is called by the function variable (function showText(whichdiv){)
PeejAvery at 2007-11-8 1:05:33 >
# 26 Re: onmouseover calling event on table column activated from another
it says its undefined. :( im giving up for the week - ill take another look on monday. Thanks for all the help :)
pixelgirl at 2007-11-8 1:06:36 >
# 27 Re: onmouseover calling event on table column activated from another
Okay, well then I will see you on Monday would be my assumption.

You can play around with it. Like I said, the error is because of the line...
link = "<a href=\"http://www..xxxxxx.com/xxx/xxx/support/" + cfd + "onMouseOver=\"showText('theInvisText" + divInt + "')\" onMouseOut=\"hideText('theInvisText" + divInt + "')\";>"
PeejAvery at 2007-11-8 1:07:41 >
# 28 Re: onmouseover calling event on table column activated from another
ok - i have the latest version of my code which still reports whichdiv as undefined. I cant find anything on the structure of this code property, and i am a bit confused why you are saying the error is somewhere in:
link = "<a href=\"http://www.xxxxxx.com/xxx/xxx/support/" + cfd + "onMouseOver=\"showText()\" onMouseOut=\"hideText()\";>"

instead of:
document.write(" <TR> <TD WIDTH=\"40%\"> " + link + size + name + twenty47 +"</font>" + "</a>" + newcol + "<DIV id=\"theInvisText" + divInt + "\" style=\"visibility:hidden;\">" + about + "</div> </TD></TR>\n")

i am not sure why it is not picking up the div id. even if i set it to something with no variable e.g "hello" or whatever it still will not pick it up. Any ideas?
pixelgirl at 2007-11-8 1:08:42 >
# 29 Re: onmouseover calling event on table column activated from another
In the showText() and hideText functions you must provide the which variable. The function then assigns which as the div it will hide or show.

Here I have changed the functions from changing the text, to alerting you what DIV it is attempting to change. What does the alert say?
link = "<a href=\"http://www.xxxxxx.com/xxx/xxx/support/" + cfd + "onMouseOver=\"alert('theInvisText" + divInt + "')\" onMouseOut=\"alert('theInvisText" + divInt + "')\";>";
PeejAvery at 2007-11-8 1:09:34 >
# 30 Re: onmouseover calling event on table column activated from another
the alert just says 'undefined.' ahh i see about the which thing - i have to pass it the variable to be processed - i thought it got it straight from the code - doh.
pixelgirl at 2007-11-8 1:10:42 >
# 31 Re: onmouseover calling event on table column activated from another
Does Firefox give any errors? What does this one say?

link = "<a href=' http://www.xxxxxx.com/xxx/xxx/support/" + cfd + "' onMouseOver=alert('" + divInt.toString() + "') onMouseOut=alert('" + divInt.toString() + "')>";
PeejAvery at 2007-11-8 1:11:39 >
# 32 Re: onmouseover calling event on table column activated from another
woo and yay oneoneone - It works!! Thanks so much :D
Heres the code if youre interested:


function PrtRow(name, about)
{
divInt++;
newcol = "</TD><TD ALIGN='LEFT'>";
size = "<font size=\"4\">";
var cfd
var bool
var hold
var twenty47
cfd = LinkName(name);
hold = b;
twenty47 = procBool(b);

link = "<a href=\"http://www.xxxxxxx.com/xxx/xxx/support/" + cfd + "' onMouseOver=\"showText(" +divInt.toString() + ")\") onMouseOut=\"hideText(" +divInt.toString() + ")\")>";
document.write(" <TR> <TD WIDTH=\"40%\"> " + link + size + name + twenty47 +"</font>" + "</a>" + newcol + "<DIV id=\""+ divInt + "\" style=\"visibility:hidden;\">" + about + "</div> </TD></TR>\n")

}

function showText(whichdiv)
{
document.getElementById(whichdiv).style.visibility ="visible";

}

function hideText(whichdiv)
{
document.getElementById(whichdiv).style.visibility="hidden";

}



PrtRow("Cantos ","hello");

thanks again! :)
pixelgirl at 2007-11-8 1:12:42 >
# 33 Re: onmouseover calling event on table column activated from another
Glad to hear it. Good luck with the rest!
PeejAvery at 2007-11-8 1:13:44 >