943,925 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 14896
  • PHP RSS
Feb 14th, 2007
0

Pass Javascript variable to PHP code

Expand Post »
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??
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
MeeraKotecha is offline Offline
15 posts
since Feb 2007
Feb 14th, 2007
0

Re: Pass Javascript variable to PHP code

Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Feb 14th, 2007
0

Re: Pass Javascript variable to PHP code

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.
Reputation Points: 8
Solved Threads: 2
Junior Poster in Training
GliderPilot is offline Offline
57 posts
since Sep 2006
Feb 16th, 2007
0

Re: Pass Javascript variable to PHP code

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.
Last edited by Rhyan; Feb 16th, 2007 at 5:08 am. Reason: url gets shortened when displayed
Reputation Points: 21
Solved Threads: 26
Posting Whiz in Training
Rhyan is offline Offline
240 posts
since Oct 2006
Feb 22nd, 2007
0

Re: Pass Javascript variable to PHP code

Hello..
Thank u all.. This problem is solved using the hiddden variables..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
MeeraKotecha is offline Offline
15 posts
since Feb 2007
Sep 12th, 2007
0

Re: Pass Javascript variable to PHP code

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..
Last edited by stymiee; Sep 12th, 2007 at 11:16 am. Reason: email addess removed
Reputation Points: 10
Solved Threads: 1
Newbie Poster
wavalker is offline Offline
11 posts
since Apr 2007
Sep 12th, 2007
0

Re: Pass Javascript variable to PHP code

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
Reputation Points: 21
Solved Threads: 26
Posting Whiz in Training
Rhyan is offline Offline
240 posts
since Oct 2006
Sep 12th, 2007
0

Re: Pass Javascript variable to PHP code

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........
.........
Reputation Points: 10
Solved Threads: 1
Newbie Poster
wavalker is offline Offline
11 posts
since Apr 2007
Sep 12th, 2007
0

Re: Pass Javascript variable to PHP code

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
Last edited by stymiee; Sep 12th, 2007 at 11:17 am. Reason: email removed
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
atplerry is offline Offline
58 posts
since Jul 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Need Help Please!
Next Thread in PHP Forum Timeline: Using the Next And Previous Buttion





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC