homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

link disappears from javascript variable
A very simle link generator to insert a voucher

 11:23 am on Nov 11, 2012 (gmt 0)

This should be very simple

<FORM NAME=makelink>
Copy the voucher code: <input type=TEXT name=voucher onchange=makethelink() size=26>
<input type=button value="Link aufbauen" onclick=makethelink()>


<script language="JavaScript">
function sete(e,h,v){if(!v){v=mt[h]}try{document.getElementById(e).innerHTML=v}catch(e){}}

function makethelink()
{ with (document.makelink) {
var link = "https://www.example.com/ecom/gb.php?c=cart&i=1168918&cl=202501&ejc=2&discount_code=" + voucher.value;
var html = link + '<br><br><a href="'+link+'" target=_blank>Download Link</a>';
sete('for_link', '',html );
alert ( html );


<span id=for_link></span>

But there is only "Download link" without link. So I inserted the alert to view waht happens. In the alert is also not the <a href for the link.

I tried what happens when I write <span style= instead of <a href=
The alert shows like expected the variable html.
But when I put <a href, the alert does not show this.

Any idea what went wrong with this very simple script?

I tried with simple links <a href=http://mysite.com>download link</a>
and it works like expected.

It only refuses to work with the online shop link and I have no idea why



 11:36 am on Nov 11, 2012 (gmt 0)

I just tested to copy my example in a simple


copy of the above code


And it works. But it does not work with my page.
The link dispappears from the var html watched by the alert


 11:47 am on Nov 11, 2012 (gmt 0)

Oh, was a shut in the own knee.
Seems my own CMS eleminated it direct out of the javascript

The solution

<a hr'+'ef

To avoid that the CMS finds an <a href instruction

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved