User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 426,187 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,827 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 6229 | Replies: 8
Reply
Join Date: Feb 2007
Posts: 15
Reputation: MeeraKotecha is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
MeeraKotecha MeeraKotecha is offline Offline
Newbie Poster

Pass Javascript variable to PHP code

  #1  
Feb 14th, 2007
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??
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2006
Location: New Jersey
Posts: 1,422
Reputation: stymiee is on a distinguished road 
Rep Power: 5
Solved Threads: 34
Moderator
stymiee's Avatar
stymiee stymiee is offline Offline
He's No Good To Me Dead

Re: Pass Javascript variable to PHP code

  #2  
Feb 14th, 2007
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Reply With Quote  
Join Date: Sep 2006
Location: Canada
Posts: 55
Reputation: GliderPilot is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
GliderPilot's Avatar
GliderPilot GliderPilot is offline Offline
Junior Poster in Training

Re: Pass Javascript variable to PHP code

  #3  
Feb 14th, 2007
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.
Reply With Quote  
Join Date: Oct 2006
Location: Sofia, Bulgaria
Posts: 135
Reputation: Rhyan is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 7
Rhyan's Avatar
Rhyan Rhyan is offline Offline
Junior Poster

Re: Pass Javascript variable to PHP code

  #4  
Feb 16th, 2007
Originally Posted by GliderPilot View Post
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 4:08 am. Reason: url gets shortened when displayed
Reply With Quote  
Join Date: Feb 2007
Posts: 15
Reputation: MeeraKotecha is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
MeeraKotecha MeeraKotecha is offline Offline
Newbie Poster

Re: Pass Javascript variable to PHP code

  #5  
Feb 22nd, 2007
Hello..
Thank u all.. This problem is solved using the hiddden variables..
Reply With Quote  
Join Date: Apr 2007
Posts: 11
Reputation: wavalker is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
wavalker wavalker is offline Offline
Newbie Poster

Question Re: Pass Javascript variable to PHP code

  #6  
Sep 12th, 2007
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
Originally Posted by MeeraKotecha View Post
Hello..
Thank u all.. This problem is solved using the hiddden variables..
Last edited by stymiee : Sep 12th, 2007 at 10:16 am. Reason: email addess removed
Reply With Quote  
Join Date: Oct 2006
Location: Sofia, Bulgaria
Posts: 135
Reputation: Rhyan is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 7
Rhyan's Avatar
Rhyan Rhyan is offline Offline
Junior Poster

Re: Pass Javascript variable to PHP code

  #7  
Sep 12th, 2007
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
" Of all the things I've lost,
I miss my mind the most...."
Mark Twain
Reply With Quote  
Join Date: Apr 2007
Posts: 11
Reputation: wavalker is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
wavalker wavalker is offline Offline
Newbie Poster

Re: Pass Javascript variable to PHP code

  #8  
Sep 12th, 2007
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........
.........
Reply With Quote  
Join Date: Jul 2007
Posts: 37
Reputation: atplerry is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
atplerry atplerry is offline Offline
Light Poster

Re: Pass Javascript variable to PHP code

  #9  
Sep 12th, 2007
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 10:17 am. Reason: email removed
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 6:41 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC