Validating a piece of script.. ish

Discussion in 'JavaScript' started by Mighty Mike, Jul 30, 2005.

  1. #1
    Hi

    Not sure if this is the correct thread to post this in but here goes.

    I am trying to validate a website and have come stuck with a piece of code

    <script language="javascript" type="text/javascript"><!--
               document.write('<a href="javascript:popupImage(\'<?php echo $extraImagePopupURL; ?>\',\'<?php echo $extraImagePopupHeight; ?>\',\'<?php echo $extraImagePopupWidth; ?>\');"><?php echo $extraImagePopupImage; ?><br /><span class="enlarge"><?php echo $extraImageURLText; ?></span></a>');
             //--></script>
    Code (markup):
    W3C gives me an error "end tag for element "SPAN" which is not open" & "end tag for element "A" which is not open" to me it looks fine but it might be all the php code in there aswell.

    Any pointers greatly appreciated

    Thanks

    Mike
     
    Mighty Mike, Jul 30, 2005 IP
  2. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #2
    * W3 validator shouldn't even see your PHP code.

    * Why do you even need document.write if you have PHP and pass static values to document.write?

    * Don't aleternate quotes in JS - it's confusing and will lead to errors. Just quote the inner quotes (e.g. document.write("<a href=\"link\">anchor</a>");)

    * It will be less code if you use <?= ?> instead of echo (e.g. <?= $extraImagePopupURL ?>)

    J.D.
     
    J.D., Jul 30, 2005 IP