Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables appearing in address bar

Status
Not open for further replies.

Shippwreck

Programmer
Oct 20, 2003
136
GB
Hi,

Firstly can i say i am very new to Javascript and have only been using it for a week now.

I have created a Google Map using there API that centres on a place and puts about 30 tags on the map each that have descriptions. That was relatively easy as a lot of the Javascript needed is given on there API site. It is the next bit that isn't on there site that i am having one very small issue with.

The bit that i have added to the map is a couple of dropdown boxes that have all the locations in. You select one to go from, and one to go to and then hit the submit button and it opens a new window that gives the directions to and from using Google Maps. All this works fine, however the first page does to odd things.

The first is that it resets itself, not really a problem just i don't know why its doing it and i would like to understand why. The second thing is that in the web address it then adds all of the variables on the page that it is passing to this new page and agian i don't know why. Ideally when you hit submit the firstpage should stay exactly the same and not change. Any help on this would be great, i have posted the Javascript code i use to get the directions below. If you want the rest of the code i can post that too but its just lifted off the Google API site.

Code:
function getDirections() {
	if (document.directions.fromselect(0).checked) {
		var from = document.directions.from1.value;
	}
	else if (document.directions.fromselect(1).checked) {
		var from = document.directions.from2.value;
	}
	
	if (document.directions.toselect(0).checked) {
		var to = document.directions.to1.value;
	}
	else if (document.directions.toselect(1).checked) {
		var to = document.directions.to2.value;
	}
	
	var directionlink = "[URL unfurl="true"]http://maps.google.co.uk/maps?q=from+"[/URL] + from + "+to+" + to + "&hl=en";
	
	window.open(directionlink);
}


"Google is god...of the internet" - Me
 
The second thing is that in the web address it then adds all of the variables on the page that it is passing to this new page and agian i don't know why.

That'll be because you are specifically adding them to the URL with this line:

Code:
var directionlink = "[URL unfurl="true"]http://maps.google.co.uk/maps?q=from+"[/URL] + from + "+to+" + to + "&hl=en";

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi,

Yes, that is the link for the new window that is opened in the last line of code, however the origional window then resets and the link changes to include both the from and to variables and looks like this:


I just want the origional window to stay unchanged and for the link in it to remain as:




"Google is god...of the internet" - Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top