PDA

View Full Version : Invalid Markup Problem - XHTML 1.0 Transitional


VosSavant
11-30-2007, 04:52 PM
I know this topic has been addressed in the past, but none of the threads discussed my particular issue.

I've removed all validation errors not related to my own code on this page (http://www.buylocalrmfu.org/sandbox/wordpress/), but I have 9 EPC-related ones remaining. They all seem to be caused by unencoded ampersands.

I encoded the ampersands on line 149 of calendar.php, so the code goes from this:

xmlhttp.open("GET", dest + "?mo=" + EPCmo + "&yr=" + EPCyr + "&EPCajax=1");to this:

xmlhttp.open("GET", dest + "?mo=" + EPCmo + "&yr=" + EPCyr + "&EPCajax=1");This removes all but 3 of the errors.

However, I am using an AJAX calendar on the front page of the site. When I click over to 2008, the following code is appended to the URL, which, incidentally, breaks the part of my page that checks page URL to determine which content to output:

[url]?amp;yr=2007&EPCajax=1&mo=1&yr=2008I notice there is a peculiar ?amp; in there instead of the & This could be it. Is there a way to fix this so the page validates and nothing gets appended to the URL?

Thanks!

Sincerely,
VosSavant

Brian
11-30-2007, 06:02 PM
The AJAX calendar is purely Beta and isn't an advertised feature.

Version 6 is no longer being developed so there will likely not be a change until Version 7.

VosSavant
11-30-2007, 07:37 PM
Brian, thanks for getting back so quickly.

Is it possible to place the JavaScript in an external .js file then, and call that file from within calendar.php? Every one of these validation errors is caused because the script is being printed in the header.

Thanks,
VosSavant

VosSavant
11-30-2007, 07:56 PM
Brian,

I found a solution. Since XHTML treats the script like normal syntax, all you need to do is add CDATA comment tags. I added them on lines 137 and 155 of calendar.php, so the relevant call to the AJAX calendar looks like this:

// AJAX JAVASCRIPT
if ($EPCAJAX==1) {
?>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
var EPCmo = <?php if ($_REQUEST['mo']>=1 && $_REQUEST['mo']<=12) echo $_REQUEST['mo']; else echo date("m"); ?>;
var EPCyr = <?php if ($_REQUEST['yr']>=1 && $_REQUEST['yr']<=5000) echo $_REQUEST['yr']; else echo date("Y"); ?>;
function loadurl(dest, EPCnav) {
try {
xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
xmlhttp.onreadystatechange = triggered;
if (EPCnav==2) {EPCmo = <?php echo date("m"); ?>; EPCyr = <?php echo date("Y"); ?>;}
if (EPCnav==1) {EPCmo--; if (EPCmo < 1) {EPCmo = 12; EPCyr --;}}
if (EPCnav==3) {EPCmo++; if (EPCmo > 12) {EPCmo = 1; EPCyr ++;}}
xmlhttp.open("GET", dest + "?mo=" + EPCmo + "&yr=" + EPCyr + "&EPCajax=1");
xmlhttp.send(null); }
function triggered() {
if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
document.getElementById("EPCcalendar").innerHTML = xmlhttp.responseText; } }
//--><!]]></script>
<?php
}