Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   PHP & Javascript together??? HOW TO (http://www.programmingforums.org/showthread.php?t=8585)

ktsirig Feb 25th, 2006 4:46 PM

PHP & Javascript together??? HOW TO
 
Hello eveybody!

I am relatively new to PHP and I have no knowledge of Javascript, but I think Javascript might be what I need
for a problem I have.
Well, say you have a PHP page with a form and the forms send a query in the Mysql database,
for example "SELECT name FROM employers WHERE salary > 5000";
The user is then presented with a page containing all the names from the query (this I have done).
What I also want to have is to give the user the ability to click on every person's name and see exactly the amount of salary he gets.
I thought of making an extra php script that would take the person's name as input (when the user clicked on the name) and then show the salary.
But I want to use pop-up window for this job, so I think Javascript is best for that...
Any hints on how to start? Basically I need some hints on how to get something fro a page and give it as input to Javasript to do the rest of the job...

DaWei Feb 25th, 2006 4:57 PM

It's hard to tell by your post: you do recognize that PHP is server side and JS is client side and there's not 'normal' interaction, right? The http transaction is one of request/response/drop communication. Interaction of the server with the mouse would certainly not be what you expect. Certainly, as you describe it, JS would be the way to go. You have to accept the fact, however, that unless you have control of the client, JS might be disabled.

Lich Feb 26th, 2006 12:06 AM

There's 2 ways I see about going about this:

1) have PHP echo out a javascript link/function that will display the number in a JS alert or a windowed pag when you click on it, passing along the salary amount to the popup page with the stuff you echoed from the database.

or

2) Have PHP echo out something to link to the pop up window and on the pop up page use a GET variable to do another database query based on the employee ID and get the data from that, then display it.

You can echo Javascript with PHP just like anything else.


All times are GMT -5. The time now is 11:26 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC