View Full Version : Test in JS Function for an invisible field!

08-08-2005, 02:04 PM

I rarely use Javascript and decided to play around with a help table which displays field/label related comments.

In order to save desktop space I have made the comments section so that the user can make the section visible or invisible. Have a problem with the following function when the section is invisible and am struggling to understand(due my complete lack of JS knowledge) how to include a check for the element being invisible!

Be grateful for any pointers

function showhelp(id){
document.getElementById("txtHelper").innerHTML = help[id];

08-08-2005, 02:54 PM
function checkHelp() {
return (document.getElementById("txtHelper").innerHTML === "");

Returns true if the txtHelper is empty.

08-08-2005, 03:34 PM
To the OP: I don't recommend your approach at all. Instead, place the comments adjacent to the appropriate sections, and hide them through script. Then, when the user wishes to see more information, reveal those hidden sections. This allows for decent fallback for any and all users.

See a previous thread (http://www.dynamicdrive.com/forums/showthread.php?t=2977) for code that could help you achieve this.


08-08-2005, 03:38 PM
Thanks Twey but I am not quite on the ball today!

The 'txtHelper' field was/is within the hidden section and looking at the source for the postback isn't on the page.

How would I modify the code to display the default string (id = "Default") on error?