Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Google Local on my site

    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.

  • #2
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:
    Code:
    <? 
    		$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 :
    Last edited by cr4z3d; 12-17-2005 at 05:14 PM.

  • #3
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <? 
    		$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.

  • #4
    New Coder
    Join Date
    Dec 2005
    Location
    Dallas, TX
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Vote for "move this thread to snippets"?
    Owner - Osiris Incorporated

    PHP and MySQL pro, and always willing to help.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •