help getting value of cell and passing to PHP file

  • Thread starter Matt Williamson
  • Start date
M

Matt Williamson

I have a table that gets generated every 5 minutes containing the drive
space on my servers. The table is sortable via an external javascript file
by clicking the column headers (using sortable.js found here:
http://www.kryogenix.org/code/browser/sorttable/) the first 2 cells of the
table are the server name and drive. When the server name in the first cell
of any row is clicked on, I want to get the value of the data from that rows
table cells and pass them to a PHP file that creates a chart of the data.
I'm pretty sure javascript is the way to go, but I haven't figured out the
right way to do it. If anyone has a suggestion as to the best way to
accomplish this, I'd really appreciate it.

TIA

Matt
 
R

Randy Webb

Matt Williamson said the following on 7/31/2005 11:26 PM:
I have a table that gets generated every 5 minutes containing the drive
space on my servers. The table is sortable via an external javascript file
by clicking the column headers (using sortable.js found here:
http://www.kryogenix.org/code/browser/sorttable/) the first 2 cells of the
table are the server name and drive. When the server name in the first cell
of any row is clicked on, I want to get the value of the data from that rows
table cells and pass them to a PHP file that creates a chart of the data.

Make the server name a button that submits a form that has hidden fields
that contain the data that PHP needs to create the chart. No JS needed
at all.

Each Server Drive would have it's own form and fields.
I'm pretty sure javascript is the way to go, but I haven't figured out the
right way to do it. If anyone has a suggestion as to the best way to
accomplish this, I'd really appreciate it.

You could use JS to do it, but why introduce a needless dependency on
client-side scripting?
 
M

Matt Williamson

I see what you're saying. I just figured since I was already using the
javascript to sort the table, that it would take less code in javascript
than doing the submit in HTML. Any html changes I make will require me to
completely re-write the script that generates the code and adding a
javascript function would be the easiest way to do it.

I've been trying to figure out how to use the hidden fields to do a post of
the data to my PHP script, but I haven't worked it out. Could you give me a
quick example of the HTML that would do what you suggested?

TIA

Matt
 
R

Randy Webb

Matt Williamson said the following on 8/1/2005 7:05 PM:
I see what you're saying. I just figured since I was already using the
javascript to sort the table, that it would take less code in javascript
than doing the submit in HTML. Any html changes I make will require me to
completely re-write the script that generates the code and adding a
javascript function would be the easiest way to do it.

<shrug> code is code, just a different language is all.

But make your drive letters links, that have a URL something like this:
<a href="drawMap.php?<drive letter here>">Humpty Dumpty Drive</a>

And then the drawMap.php file can pick it up and draw the map.

Since PHP is generating the page every 5 minutes, it would know the
parameters to add to the URL that it needs, such as drive letter, drive
name, free space, etc...

And I promise, that is a *lot* easier than trying to have JS do it.
 
M

Matt Williamson

I figured out how to do it after reading a few older posts and munging the
code I found in them. I decided it was better to just use one form and use
some javascript to update the hidden fields and submit it to my PHP script.


Matt Williamson said:
Yeah, that would be if that were the case. The code is being generated via a
locally run VBScript file using task scheduler on one of my servers. I put
an example of the html output up on my own public webserver here:
http://www.crxtasy.org/ds/drivespace.htm Right now, I have the server name
being written as a hyperlink just using local filesystem links. I thought
about what I'd like to do a little more and decided that I'd rather be able
to click on any cell entry and have it send that value along with the server
and drive to the PHP script so I can have a graph of the server and drive in
question and get the used space or freespace or whatever else I add to the
original script. Is that still workable using the form and hidden fields? I
think that might require some javascript as well though.. I've spent the
last few hours trying to find any examples that would show how to do it, but
I haven't found anything yet.

Thanks for your help

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top