PDA

View Full Version : Does the page have to reload once a user clicks on the submit button?


jules.webb286095
03-03-2009, 02:45 PM
I am using the current version of Pro Maps for Google and Dreamweaver CS3. I have included a form to retrieve directions.

I am wondering if there is any way to prevent the page from completely reloading once the submit button is clicked? Having to scroll back down to the map is not the smoothest of transitions for users and I was wondering if there was any way around that.

Thanks for any enlightenment!

Jules

Ray Borduin
03-03-2009, 02:51 PM
There is a way to do it with scripting by hand, but no way from within the wizard.

An example (not working because of a bad key, but you could copy and paste the source to play with it) is at: http://www.buyftanow.com/AboutUs.php

jules.webb286095
03-03-2009, 04:32 PM
thanks for the response Ray.

I did copy and paste the source code into Dreamweaver, used my google key and took a look. I was assuming that the hand coded script was already on this page, but considering it doesn't have a form on it and I didn't see any notable differences in the javascript, I'm thinking you believe I can come up with the hand coding myself. Oh how I wish that were true, but there are oh so many things to learn, and only so much time to do the learning! I am working at it, but for now I would need more direction than your reply included. I had thought that maybe this was something that had already been done and the info could be passed along.

Thanks for you time

Jules

Ray Borduin
03-03-2009, 04:53 PM
It is actually implemented on that page. Use a copy of that page and only change the api key so it works on your server to see how it works.

To do it yourself you would use code like:

onClick="wagmp_map_1(document.getElementById('fromaddress') .value+', '+document.getElementById('fromcity').value)"

with the updated functions from that example this would work

jules.webb286095
03-03-2009, 09:45 PM
I'm sorry Ray, I'm just not getting it.

Just to make sure we understand each other:
I want to prevent the page from reloading so that after the submit button on the getDircections form is clicked the information is loaded into the wagmp_directions_1 div without the whole page having to reload. I am not interested in a separate info window opening up. The function your example code came out of (see below) doesn't look like it'll do what I want. And the buyFTANow.com page you referred me to doesn't have a form to get directions anyways, which is confusing to me and why I don't think we are talking about the same thing. Would you mind have another go at an explanation for me?

Thanks, I appreciate you taking the time!
Jules

function updateInfoWindow() {
wagmp_map_1_obj.markers[0].openInfoWindowHtml('<span style="font: 12px Verdana, Arial, Helvetica, sans-serif; color: black;"><strong>from address:</strong><br><input id="fromaddress" type="text"><br><strong>city, state:</strong><br><input id="fromcity" type="text"><br><input type="button" value="get directions" onClick="wagmp_map_1(document.getElementById(\'fromaddress\ ').value+\', \'+document.getElementById(\'fromcity\').value)"></span>')
}

Ray Borduin
03-04-2009, 09:26 AM
The functions on the page were updated to work. I think you would need a good understanding of writing javascript to customize the example.

The form in the example is dynamically created in the info window... but it would be a simplified sample for what you need. You are going to need a javascript expert if you can't understand the example.

theaellen380465
05-24-2009, 03:36 AM
One way to reload the page but not the map settings is to use AJAX, or Asynchronous Javascript. This lets the submit button call the server, and the server responds with the answer, the section of the page gets updated (via the HTML document object model e.g. var newSection = getElementById('thisTag')

It works beautifully. I did mine "by hand" but there are many frameworks and helpers out there for non programmers. This example you cited is the perfect application for AJAX because you don't want to reload the entire page if it has a map on it.

Thea