I am familiar with php, but not so much with JavaScript.
I found a Google Gadget that basically gets driving directions that I want to use on my web site. Basically there are two text boxes: one for starting point, and one for destination. I want the destination box to be filled in based on a php variable that controls the location.
In a nut shell: I need to use a php variable $locgoomaps and pass it to the javascript and use it within the SRC tag. But, being very new to javascript, I am finding this to be quite frustrating.
- Currently this is being placed in the body of my page.
What I have been able to accomplish so far is this:
<SCRIPT LANGUAGE="javascript"><!--
<?php print("var resloc = " . $goomapsloc . " \
");?>
alert(resloc);
Php will write the java code so that I can easily pass the variable. I have the alert to test that it is passed correctly (and it is working).
Now, I still can’t figure out how to get my javascript ‘resloc’ variable to work with my src tag.
I have tried to do an src-“http://google.com. . blah. . blah. . loc=”+resloc+“&. . blah blah blah”
But this is not working. Nothing I have tried seems to work.
Here is the untouched src code that I need to pass my variable within:
src="http://www.gmodules.com/ig/ifr?url=http://hosting.gmodules.com/ig/gadgets/file/108836475058194723393/driving_directions.xml&up_from=&up_to=
[COLOR=“Red”]
twin%20peaks%20blvd%2C%20san%20francisco
[/COLOR]
&up_country=0&synd=open&w=400&h=140&title=Get+Directions&lang=en&country=CH&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"
The red text is what I need to be dynamic and replace with my variable, but I can’t seem to get this to come together . . where I pass the php variable to javascript and can use the new js variable in the src.
Any suggestions?
Thanks