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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

show / hide row 1

Status
Not open for further replies.

snowboardr

Programmer
Joined
Feb 22, 2002
Messages
1,401
Location
PH
I have working show / hide table row code (see below)

How can i do an javascript function that checks to see if the cell is being closed or opened so then I can load a different page on close in the iframe

this is my code for loading the iframe page

Code:
function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;   
    return false;
  }
  else return true;
}

Code:
<script type="text/javascript">

/* call onload with table id(s) */
function TR_set_toggle()
{
	/* toggleRow method */
	var toggleRow = function()
	{
		this.style.display = ((this.style.display == '') ? 'none' : '');
		return false;
	}

	for (var oTable, a = 0; a < arguments.length; ++a)
	{
		oTable = document.getElementById(arguments[a]);
     		var r = 0, row, rows = oTable.rows;
     		while (row = rows.item(r++))
			row.toggle = toggleRow;
	}

	/* convenience function */
	self.toggleRow = function(row_id)
	{
		document.getElementById(row_id).toggle();
	}
}

onload = function()
{
	TR_set_toggle('foo');
}


function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;   
    return false;
  }
  else return true;
}

</script>

as you can see below i load the page i want when they "open the row" but I want to change it back to "blankpage.html" when they close it.... this way its more efficient.. and other reasons too..

Code:
<a href="#null" class="cli" onclick="toggleRow('rowid<%=tid%>');loadIframe('frame<%=tid%>','post.asp')">

thanks a million!
 
You should remove the loadIframe call from the onclick, and modify the parameters being passed:

Code:
onclick="toggleRow('<%=tid%>');"

And modify the toggleRow function accordingly. You'll have to make it a global function rather than a variable, however (not sure why you even have it set up as a variable... is it even accessible outside the TR_set_toggle function?)

Code:
function toggleRow(tid) {
	if (this.style.display == 'none') {
		this.style.display = '';
		loadIframe('frame' + tid, 'post.asp');
	} else {
		this.style.display = 'none';
		loadIframe('frame' + tid, 'blankpage.html');
	}
	return false;
}

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks Dan! However its not loading the post.asp page its just staying on blankpage.html. Any ideas?

Code:
<script type="text/javascript">
function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;   
    return false;
  }
  else return true;
}




/* call onload with table id(s) */
function TR_set_toggle()
{


	for (var oTable, a = 0; a < arguments.length; ++a)
	{
		oTable = document.getElementById(arguments[a]);
     		var r = 0, row, rows = oTable.rows;
     		while (row = rows.item(r++))
			row.toggle = toggleRow;
	}

	/* convenience function */
	self.toggleRow = function(row_id)
	{
		document.getElementById('rowid'+row_id).toggle();
	}
}

onload = function()
{
	TR_set_toggle('foo');
}



	/* toggleRow method */
	function toggleRow(tid) {
		if (this.style.display == 'none') {
			this.style.display = '';
			loadIframe('frame' + tid, 'post.asp');
		} else {
			this.style.display = 'none';
			loadIframe('frame' + tid, 'blankpage.html');
		}
		return false;
	}


</script>



Code:
 <a href="#null" class="cli" onclick="toggleRow('<%=tid%>');"><%=tcommentcount%> Comments</a>

Site San Diego www.sitesd.com

 
Right before this line:

Code:
if (this.style.display == 'none')

put this:

Code:
alert(this.style.display)

If it doesn't alert 'none' when it should, that's the problem.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top