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 402,047 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 2,504 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: 453 | Replies: 12 | Solved
Reply
Join Date: Jul 2008
Posts: 13
Reputation: dragonflyuk is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
dragonflyuk dragonflyuk is offline Offline
Newbie Poster

PHP and Javascript

  #1  
Jul 24th, 2008
I have a javascript that looks up some details on googlemaps for me, then returns them to a php script that does the web bit I actually need doing. I actually works by filling in a form and submitting it, so that php can handle the data.

However I now need to call the script combo from another script. With a normal straight php script I could use curl to effectively run the second script, however with the combo this approach won't run the javascript.

Any ideas how I can get round this anyone?
Dragonfly Services - Same Day Courier
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 600
Reputation: R0bb0b is on a distinguished road 
Rep Power: 2
Solved Threads: 53
R0bb0b's Avatar
R0bb0b R0bb0b is online now Online
Practically a Master Poster

Re: PHP and Javascript

  #2  
Jul 24th, 2008
Originally Posted by dragonflyuk View Post
I have a javascript that looks up some details on googlemaps for me, then returns them to a php script


I don't understand why you don't just do this with Curl, then you could run the entire script from cron or from another php file or whatever you want.
Last edited by R0bb0b : Jul 24th, 2008 at 5:09 pm.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
Reply With Quote  
Join Date: Jul 2008
Posts: 13
Reputation: dragonflyuk is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
dragonflyuk dragonflyuk is offline Offline
Newbie Poster

Re: PHP and Javascript

  #3  
Jul 24th, 2008
The javascript gets details from googlemaps, then submits the to a php script whic formats them, and stores them in a mysql database as a cache.

The lookup needs to be triggered by data entered into a html form, and the final result is displayed on another page. The final result involves several lookups of different sorts, but this is the only one that I've not managed to do without using javascript.
Dragonfly Services - Same Day Courier
Reply With Quote  
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 600
Reputation: R0bb0b is on a distinguished road 
Rep Power: 2
Solved Threads: 53
R0bb0b's Avatar
R0bb0b R0bb0b is online now Online
Practically a Master Poster

Re: PHP and Javascript

  #4  
Jul 25th, 2008
OK, javascript is client side = must be parsed by the web browser.

So this means that the possibility of php parsing the javascript and running it is out of the realm of possibility, so you need a work around.

How about this, in your php script, if the google maps data is non existent, redirect to the page with the google maps javascript, then redirect back to the php script with the data either in the url or in a session variable.
Last edited by R0bb0b : Jul 25th, 2008 at 12:38 am.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
Reply With Quote  
Join Date: Jul 2008
Posts: 13
Reputation: dragonflyuk is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
dragonflyuk dragonflyuk is offline Offline
Newbie Poster

Re: PHP and Javascript

  #5  
Jul 25th, 2008
I suppose I could have a "Processing" page that does the javascript and bounces back, suppose that could work.
Dragonfly Services - Same Day Courier
Reply With Quote  
Join Date: Jul 2008
Posts: 13
Reputation: dragonflyuk is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
dragonflyuk dragonflyuk is offline Offline
Newbie Poster

Re: PHP and Javascript

  #6  
Jul 25th, 2008
Think I've got that to work now. It's not pretty yet, but see what you think.

www.route-information.co.uk
Dragonfly Services - Same Day Courier
Reply With Quote  
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 600
Reputation: R0bb0b is on a distinguished road 
Rep Power: 2
Solved Threads: 53
R0bb0b's Avatar
R0bb0b R0bb0b is online now Online
Practically a Master Poster

Re: PHP and Javascript

  #7  
Jul 25th, 2008
Very nice, probably about as good as it is going to get.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
Reply With Quote  
Join Date: Jul 2008
Posts: 13
Reputation: dragonflyuk is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
dragonflyuk dragonflyuk is offline Offline
Newbie Poster

Re: PHP and Javascript

  #8  
Jul 27th, 2008
Originally Posted by R0bb0b View Post
Very nice, probably about as good as it is going to get.


Thanks
Dragonfly Services - Same Day Courier
Reply With Quote  
Join Date: Jul 2008
Posts: 13
Reputation: dragonflyuk is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
dragonflyuk dragonflyuk is offline Offline
Newbie Poster

Re: PHP and Javascript

  #9  
13 Days Ago
Originally Posted by R0bb0b View Post
Very nice, probably about as good as it is going to get.



Looking at our logs, I notice that quite a few users, look at the page then go back, probably to change some details or similar, however back doesn't work because of the intermediary page. Any ideas how to avoid the intermediary page been the default "back" location?
Dragonfly Services - Same Day Courier
Reply With Quote  
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 600
Reputation: R0bb0b is on a distinguished road 
Rep Power: 2
Solved Threads: 53
R0bb0b's Avatar
R0bb0b R0bb0b is online now Online
Practically a Master Poster

Re: PHP and Javascript

  #10  
12 Days Ago
You can create your own back button which utilizes the javascript window.history object but I'm pretty sure that there is no way to manipulate the behavior of the back button.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
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 11:35 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC