Solved

Javascript hyperlink

Posted on 2010-08-24
7
229 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now