Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show hide table row onclick of radion button

Status
Not open for further replies.

mat41

Programmer
Mar 7, 2004
91
AU
Hello

I am using the following function to show / hide a <tr> onclick of a radio button however it does not work in Firefox. Works fine in IE. Please help??

function toggleT(_w,_h)
{
if (document.all)
{
if (_h=='s') eval("document.all."+_w+".style.display='block';");
if (_h=='h') eval("document.all."+_w+".style.display='none';");
}
}

Am fireing like so:

To show - toggleT('issueSubject','s')
To hide - toggleT('issueSubject','h')

Thanking you
 
That's probably because 'document.all' is an IE-only collection.

This should work cross-browser (and avoiding the use of eval), assuming 'issueSubject' is the ID of the row:

Code:
function toggleT(_w, _h) {
	var theRow = document.getElementById(_w);
	if (_h == 's') theRow.style.display = 'block';
	if (_h == 'h') theRow.style.display = 'none';
}

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top