Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 25th, 2006, 4:46 PM   #1
ktsirig
Programmer
 
Join Date: Oct 2005
Posts: 54
Rep Power: 3 ktsirig is on a distinguished road
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...
ktsirig is offline   Reply With Quote
Old Feb 25th, 2006, 4:57 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Feb 26th, 2006, 12:06 AM   #3
Lich
Professional Programmer
 
Lich's Avatar
 
Join Date: May 2005
Location: Detroit
Posts: 254
Rep Power: 4 Lich is on a distinguished road
Send a message via AIM to Lich Send a message via MSN to Lich
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.
__________________
--John Cruz
Web Developer
www.cruzweb.net
Lich is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:28 PM.

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