Fast Loans - Loans - Cheap Flights - Mortgage - Flights

PDA

View Full Version : Validating a piece of script.. ish


Mighty Mike
Jul 30th 2005, 11:13 am
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>

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

J.D.
Jul 30th 2005, 12:26 pm
* 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.