Javascript hyperlink

I really don't know any javascript and need a little help.  I am passing variables and I would like to use one of them to create the link address within a hyperlink.

The variable I would like to use is "weburl"  you can see the piece of code here and I don't know how to write it to the a tag.
    function createMarker(point, name, address, phone, weburl_fender) {
      var marker = new GMarker(point);
      var html = '<b>' + name + '</b> <br/>' + address + '<br />' + phone + '<br /> <span class="map-link"><a href="weburl>">click here</a></span>';
      GEvent.addListener(marker, 'click', function() {
      return marker;

Open in new window

Who is Participating?

Improve company productivity with a Business Account.Sign Up

darkyin87Connect With a Mentor Commented:
Hi rgranlund,

I tried this with a sample html markup and it works fine. You can test it too. Are you sure you are not passing an empty parameter to the function createMaker?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

<html xmlns="">
<link href="" type="text/css" />
<script type="text/javascript">

function createMaker(point, name, address, phone, weburl_fender)
      var html = '<b>' + name + '</b> <br/>' + address + '<br />' + phone + '<br /> <span class="map-link"><a href="' + weburl_fender + '">click here</a></span>';

<body onload="createMaker('point','name','address','phone','')">
Just from the top of my head i see the parameter being passed is weburl_fender and not just weburl
I believe this is what you are looking for.

var html = '<b>' + name + '</b> <br/>' + address + '<br />' + phone + '<br /> <span class="map-link"><a href="'+weburl_fender+'">click here</a></span>';
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

rgranlundAuthor Commented:
This statment does not work:

        var html = '<b>' + name + '</b> <br/>' + address + '<br />' + phone + '<br /> <span class="map-link"><a href="'+weburl_fender+'">click here</a></span>';
Can you be more specific. Can you do an alert(html); after the line where you have declared the variable and let me know what you get.
rgranlundAuthor Commented:
It leaves the variable empty:
<a href="'+weburl_fender+'">

the url does not replace the weburl_fender
rgranlundAuthor Commented:
Maybe it is because the document that is creating the variable has an issue.  I need to correctly configure this code:

I have delimiters in my feed that I must remove and make the following work:


$str = $weburl_fender;    // Can replace this with your mysql_result call
$strArray = explode("|||" , $str);     // Breaks the string into an array of strings
foreach( $strArray as $weburl_fender)        // assigns $strArray[0] to $value until it goes through the whole array

while ($row = @mysql_fetch_assoc($result)){
  $node = $dom->createElement("marker");
  $newnode = $parnode->appendChild($node);
  $newnode->setAttribute("name", $row['custname']);
  $newnode->setAttribute("address", $row['address']);
  $newnode->setAttribute("phone", $row['phone']);
  $newnode->setAttribute("weburl_fender", $row['weburl_fender']);
  $newnode->setAttribute("latitude", $row['latitude']);
  $newnode->setAttribute("longitude", $row['longitude']);
  $newnode->setAttribute("distance", $row['distance']);

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.