Jump to content

How to insert <a> in a document.write method?


Zyphon

Recommended Posts

Hello fellas. I'm trying to make a "menu" using JS and php.The trick is that the document.write() has to contain an <a href="link"> and this link has to be a variable that i define in the top of the document.The question is. Can i insert variables as a link inside the document.write() method?My current code is:

<table border="1" cellpadding="2" cellspacing="0" width="130px"> <tr>  <td>  <script type="text/javascript">  document.write('<a href="' + PageDA + '"><img src="Engelsk_flag.jpg" border=1" /></a>')  </script>  </td> </tr></table>

The link doesn't work. I dont know how to insert the variable into a link.If i can't do that how do i then work it out ?

Link to comment
Share on other sites

Ok. Fixed the quotation mark, and worked on it abit. still doesn't work.The variables that i want to call is in the head section of the page. Should be fine and cool.It looks like this:

<script type="text/javascript">var Location="Basic Information"var PageEN="infoEN.php"var PageDA="infoDA.php</script>

Then my newly made script looks like this (still doesn't work)

<table border="1" cellpadding="2" cellspacing="0" width="130px"> <tr>  <td align="center">  <script type="text/javascript">  document.write('<a href="' + PageEN + '"><img src="Engelsk_flag.jpg" border="1" /></a>')  document.write('<a href="' + PageDA + '"><img src="Dansk_flag.jpg" border="1" /></a>')  </script>  </td> </tr> <tr>  <td align="center">Change Language</td> </tr></table>

Still dont know what is wrong X.x

Link to comment
Share on other sites

jkloth what i mean with that it doesn't work is that it shows... nothing. There's only an empty table cell in the table. There's not even any images.And they are in the same folder.Don't really understand why. :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...