Web Design Forums

Welcome! Please register or log in: Forgot your password? Why register?
You are here: Web Design Forums » Programming Help » PHP » Calling a JavaScript from PHP and processing return value RSS

Calling a JavaScript from PHP and processing return value

This thread was started by curare and has been viewed 497 times, and contains 1 replies, with the last reply made by Anant.
Post Reply
1
50 points at 100%
curare, WDF User Private message  
Posted December 23 '09 at 01:04 PM
      Posts: 48
I'm doing some work with Google Maps and need to batch process some locations from a CSV import and return the lat/long values to input into a database. My geocode lookup works fine, but I need to be able to call my code from PHP and get the return values.

Currently, I have a form to input locations one at a time and just call my gecode onsubmit wich works perfectly. But how can I call a JavaScript routine from PHP directly?

I was thinking something along the lines of:

<?php
...

$address_string "123 Nowhere Ave., Somewhere, someplace, somezip, USA";

echo 
'<script type="text/javascript">find_location("$address_string"); return false;</script>';

...
?>

But I somehow have to get return values in my PHP, but one thing at a time. Any help is appreciated.

Advertisement Register for free to hide these ads and participate in discussions!

2
View Anant's reputation
Anant, WDF User Private message  
Posted January 12 '10 at 06:46 AM
      Posts: 50
Hi,

I have done some coding for this in my previous project. It might help you, although not able to understand your problem fully.

Home.php

<form name="search" class="cmxform" id="homeForm" action="<?php echo base_url(); ?>search/result" method="POST">
</div>
<div class="searchWhat">
<input type="text" name="searchTxtBox" id="searchTxtBox">
</div>
<div class="searchWhere">
<input type="text" name="cityTxtBox" id="cityTxtBox" value="<?php echo $city_where;?>" onblur="showAddress(this);">
</div>
<input type="hidden" id="citylatlng" name="citylatlng">
</div>
<script type="text/javascript">
function showAddress(address) {
$("#citylatlng").val('');
var geocoder = null;
var geocoder = new GClientGeocoder();
geocoder.getLatLng(
address,
function(point) {
$("#citylatlng").val(point);
} );
}
</script>
<div class="searchBtn">
<input type="image" src="<?php echo base_url();?>images/c2c-btn.jpg"/>
</div>
</form>

Hope this coding will help you

Post Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Processing Form Script Error Abstract PHP 8 March 23 '09 10:15 PM
PHP Form processing... redirect durantz PHP 7 March 14 '09 08:39 PM
Prepared statements (PHP 5 / MySQL 4.1.x) rosland Coding Articles & Tutorials 0 February 25 '05 08:18 PM
ARRGH! php processing javascript and i can't stop it!! jf1288 PHP 1 August 14 '04 02:23 AM
Php script processing a flash form problem Bazrazmataz PHP 8 May 22 '04 06:04 AM