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

Pass Javascript variable to PHP code

Hello..
I am designing a page in which if i click "call" button the button gets disabled and the timer starts.. This code is in JavaScript..(coz I couldn't write the PHP code to start timer on a button click)

Now.. I need to pass the time of the "call" button click to the DataBase along the other fields of the database...

How this is done??

MeeraKotecha
Newbie Poster
15 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 
stymiee
He's No Good To Me Dead
Moderator
3,360 posts since May 2006
Reputation Points: 161
Solved Threads: 38
 

The only possible way to do this with PHP and Javascript is to have the javascript to refresh the page, best way is with a hidden form, than have PHP detect the form submition and than execute the script to add info to the database.

Ajax as mentioned before is another option.

PHP is a server side script and is processed by the server, the client browser never sees the PHP. Javascript is processed by the client browser. Therefor javascript cannot call PHP functions.

GliderPilot
Junior Poster in Training
86 posts since Sep 2006
Reputation Points: 8
Solved Threads: 4
 
The only possible way to do this with PHP and Javascript is to have the javascript to refresh the page, best way is with a hidden form, than have PHP detect the form submition and than execute the script to add info to the database.

The other way is to use GET method to call the php script, where the start time value is passed as a get variable.

e.g. yoursite/php_script_name.php?start_time=time.from.js

This should be captured on the other side by the php with $_GET['time.from.js'];

Of course though, Ajax is best sollution for your problem.

Rhyan
Posting Whiz in Training
240 posts since Oct 2006
Reputation Points: 21
Solved Threads: 26
 

Hello..
Thank u all.. This problem is solved using the hiddden variables..

MeeraKotecha
Newbie Poster
15 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

hi MeeraKotecha
can u tell me how can i use timer in my webpages i am making one pages in which i need timer function in this pages

regards
wavalker Hello..
Thank u all.. This problem is solved using the hiddden variables..

wavalker
Newbie Poster
11 posts since Apr 2007
Reputation Points: 10
Solved Threads: 1
 

Depends what do you need the timer for - just to reload a page, or for something else. Just google javascript timer and you will get tons of scripts.

Good luck

Rhyan
Posting Whiz in Training
240 posts since Oct 2006
Reputation Points: 21
Solved Threads: 26
 

thank u Rhyan
one thing more i am not able to call open dialog box in php to upload image if u have any idea plz help me........
.........

wavalker
Newbie Poster
11 posts since Apr 2007
Reputation Points: 10
Solved Threads: 1
 

can u please tell me how can i use timer in my webpages i am making one pages in which i need timer function in this pages and what is ajax mean and its uses

atplerry
Junior Poster in Training
58 posts since Jul 2007
Reputation Points: 10
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You