954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Toggle value in a table cell, from php ?

(If you are familiar with Memcached, better) can take a look at the img.

on the third column (named 'Value'), I need to put a 'button/link' that when clicked it will display/hide the content of the cell. In a sort of javascript 'toggle' function. (i'm not sure which to use: found a nice mootools styling here but i'm stuck on how to use it in this script.

Can you help me modify this table, for the third column to display the result when a button in this cell is clicked (and then click again and hide it)?

Here is the snippet for the table:

$a = getMemcacheKeys();

echo "<table class='prettytable'><tr><th>Key</th><th>Date Set</th><th>Value</th></tr>";

foreach ($a as $key => $v)
{
	if (count($v) == 3)
	echo "<tr><td>{$key}</td><td>" . date('r',$v[1]) . "</td><td class='button'><pre>" . print_r($v[3],1) . "</pre></td></tr>\n";
}

echo "</table>";


thanks

Attachments ffff.png 11.35KB
globalaction
Newbie Poster
1 post since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

To toggle something use jQuery and .toggle()
http://api.jquery.com/toggle/

This will toggle display:none;

Edit something like this...

<script type="text/javascript">
$('#clickme').click(function() {
  $('#cell').toggle('slow');
});
</script>
Danny159
Junior Poster in Training
93 posts since Jul 2011
Reputation Points: 24
Solved Threads: 1
 

It's not really necesary to use jquery for that even, document.getElementById().style.display does it all.

Remember, PHP is a server side language: you can't do anything with it AFTER the user has the page on his screen, unless you want to use AJAX.
But to be honest, that sounds a little to complex for a small script like this

phoenix_2000
Junior Poster
107 posts since Sep 2011
Reputation Points: 40
Solved Threads: 12
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: