Forum Moderators: open
var html = "<b>" + name + "</b> + "<br/>" + "<a href='http://www.example.com/Contact/retailDesc.php?zipcode='" + zip + "> click here </a>" ;
Any help is appreciated.
[edited by: jatar_k at 6:33 pm (utc) on Nov. 13, 2007]
[edit reason] please use example.com [/edit]
var html = "<b>" + name + "</b>";
html += "<br/>";
html += "<a href='http://www.example.com/mypage.php?zipcode=" + zip + "> click here </a>";
I've highlighted the problems in the original line:
var html = "<b>" + name + "</b>+ "
<br/>" + "<a href='http://www.example.com/mypage.php?zipcode='
" + zip + "> click here </a>";
If that still doesn't work, try simply:
alert( zip);
Which should popup and tell you what it thinks zip contains.
Again, as we've got a large and complex string building up, let's break it down and make it more readable:
var href = "http://www.example.com/mypage.php";
href += "?zipcode="+ zip;
href += "&efinno="+ efin;
'
html += "<a href=
"+ href +"'
target='
_blank'
>";
html += "<b>click here for Landmark information.</b> </a>";
Note the quotation marks (I've highlighted them for you), the " is used around the JavaScript strings, and the ' around the HTML strings. If we used " all the time we'd prematurely end the JavaScript string.