Solved

Javascript hyperlink

Posted on 2010-08-24
7
228 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
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…

706 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

19 Experts available now in Live!

Get 1:1 Help Now