...

View Full Version : Google Local on my site



cr4z3d
12-17-2005, 03:14 PM
Hello, I've been trying to do this all morning.. My current set up is a form that gets someone to enter "City, State" then when they hit the submit button i used PHP to set up a variable called $location which was set to google.com/maps?q=from%3A+city,+state+to%3A+city,+state the $to variable is sent from a hidden input and is equal to the club they want to go to. After that i do a few string changes to get rid of the spaces. after its' all done it becomes $location. What i currently have is a simple window.open() using javascript to open up the window. This works fine with one major problem.. popup blockers stop it from opening and the people browsing this site aren't exactly tech savy. They usually have no idea how to allow popups and this becomes a problem. The only reason i have it set up the way i do now is because my javascript is very limited.. but my php is pretty good. Is there a better way to open up the new window without popup blockers stopping it? If not do you know a way I could set up javascript to change a hidden input on the fly as the person enters their info so i can just use method="GET" and have the action to google.com/maps..

Thanks for the help in advance.

cr4z3d
12-17-2005, 04:01 PM
Ok.. I've done a few google searches and I don't really have time to really learn javascript right now cuz I have deadlines to meet with this project. This could be horribly wrong but i'm not sure how to debug javascript since it does not give you errors like php does.. either that or it's right and just not working.

Here's what I have so far:

<?
$n_val = $_GET['n'];
if ($n_val == 'platinum') {
$to = "13+Paterson+St,+New+Brunswick,+NJ+(Platinum)" ;
}
elseif ($n_val == 'goodtimez') {
$to = "34+okner+parkway,+livingston,nj";
}
echo $to;
?>
<script language="text/javascript">
function goDirect()
{
var entry = document.directions.citystate.value
var to = "<? echo $to; ?>"
var from = entry.replace(" ", "+")
var q = "from%3A+" + from + "+to%3A+" + to
var loc = "http://www.google.com/lochp?hl=en&tab=wl&q=" + q
window.open(loc)
}
</script>
<form method="post" name="directions" onsubmit="goDirect()">
<label for="citystate">City, State</label>
<input name="citystate" value="<? echo $citystate; ?>" />

<input type="button" name="dir" value="Get Directions" onclick="goDirect()" />
</form>

Keep in mind all the spaces have to be replaced with + and the %3A is a :

cr4z3d
12-17-2005, 05:46 PM
<?
$n_val = $_GET['n'];
if ($n_val == 'platinum') {
$to = "13+Paterson+St,+New+Brunswick,+NJ+(Platinum)" ;
}
elseif ($n_val == 'goodtimez') {
$to = "34+okner+parkway,+livingston,nj";
}
?>
<script language="javascript">
function goDirect()
{
var entry = document.directions.citystate.value
var to = "<? echo $to; ?>"
var from = entry.replace(" ", "+")
var q = "from%3A+" + from + "+to%3A+" + to
var loc = "http://www.google.com/lochp?hl=en&tab=wl&q=" + q
window.open(loc)
}
</script>
<form method="post" name="directions" onsubmit="goDirect()">
<label for="citystate">City, State</label>
<input name="citystate" value="<? echo $citystate; ?>" />

<input type="button" name="dir" value="Get Directions" onclick="goDirect()" />
</form>

wow all i needed was to change "text/javascript" to "javascript".. well that's it.. i don't know if anyone will have any use of it but go for it.

Osiris
12-17-2005, 09:28 PM
Vote for "move this thread to snippets"? :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum