Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

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() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }

Open in new window

Avatar of darkyin87
darkyin87

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>';
Avatar of Robert Granlund

ASKER

This statment does not work:

[code]
        var html = '<b>' + name + '</b> <br/>' + address + '<br />' + phone + '<br /> <span class="map-link"><a href="'+weburl_fender+'">click here</a></span>';
[/code]
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.
It leaves the variable empty:
<a href="'+weburl_fender+'">

the url does not replace the weburl_fender
ASKER CERTIFIED SOLUTION
Avatar of darkyin87
darkyin87

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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:

[code]

$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']);
}

[/code]