Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Javascript hyperlink

Posted on 2010-08-24
7
Medium Priority
?
236 Views
Last Modified: 2012-05-10
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

0
Comment
Question by:rgranlund
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 4

Expert Comment

by:darkyin87
ID: 33512762
Just from the top of my head i see the parameter being passed is weburl_fender and not just weburl
0
 
LVL 4

Expert Comment

by:darkyin87
ID: 33512776
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>';
0
 
LVL 7

Author Comment

by:rgranlund
ID: 33513258
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]
0
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
LVL 4

Expert Comment

by:darkyin87
ID: 33513918
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.
0
 
LVL 7

Author Comment

by:rgranlund
ID: 33514009
It leaves the variable empty:
<a href="'+weburl_fender+'">

the url does not replace the weburl_fender
0
 
LVL 4

Accepted Solution

by:
darkyin87 earned 200 total points
ID: 33514210
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"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<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>';
     alert(html);
}
</script>

</head>
<body onload="createMaker('point','name','address','phone','www.domain.com')">
                  <h1>Title</h1>
</body>
</html>
0
 
LVL 7

Author Comment

by:rgranlund
ID: 33514985
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]
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question