PDA

View Full Version : Invalid character error?


jcdevelopment
05-21-2008, 04:46 PM
Not sure why but this script is giving me this error? When i click on the add product it come up.

It says the error appears on line 26
which would be


spantag.innerHTML += " " + header[0].lastChild.text + " " + "<a href="#" onclick='AddRemoveItem(\"Remove\");'>Remove Item</a>";


here is the script

var xHRObject = false;
if (window.XMLHttpRequest)
{
xHRObject = new XMLHttpRequest();
}
else if (window.ActiveXobject)
{
xHRObject = new ActiveXObject("Microsoft.XMLHTTP");
}

function getData()
{
if (xHRObject.readyState == 4 && xHRObject.status == 200)
{
var serverResponse = xHRObject.responseXML;
var header = serverResponse.getElementByTagName("book");
var spantag = document.getElementById("cart");
spantag.innerHTML = "";
for (i=0; i<header.length; i++)
{
if (window.ActiveXObject)
{
spantag.innerHTML += " " + header[0].firstChild.text;
spantag.innerHTML += " " + header[0].lastChild.text + " " + "<a href="#" onclick='AddRemoveItem(\"Remove\");'>Remove Item</a>";
}
else
{
spantag.innerHTML += " " + header[0].firstChild.textContent;
spantag.innerHTML += " " + header[0].lastChild.textContent + " " + "<a href="#" onclick='AddRemoveItem(\"Remove\");'>Remove Item</a>";
}
}
}
}

function AddRemoveItem(action)
{
var book = document.getElementById("book").innerHTML;

if(action=="Add")
{
xHRObject.open("GET", "managecart.aspx?action=" + action + "&book=" + encodeURIComponent (book)+ "&value=" + Number(new Date), true);
}
else
{
xHRObject.open("GET", "managecart.aspx?action=" + action + "&book=" + encodeURIComponent (book)+ "&value=" + Number(new Date), true);
}
xHRObject.onreadystatechange = getData;
xHRObject.send(null);
}

If you need the asp file and html file let me know.

here is the command to pull it


<a href="#" onclick="AddRemoveItem('Add');" >Add to Shopping Cart</a>


Thanks

Philip M
05-21-2008, 05:17 PM
"<a href="#" onclick='AddRemoveItem(\"Remove\");'>Remove Item</a>";

Double quotes within double quotes. Change to:-

"<a href='#'

jcdevelopment
05-21-2008, 05:44 PM
That will work, you are a genious!