PDA

View Full Version : Duplicating Script



mdj101
02-21-2008, 12:13 AM
Hi All,

I have the following code that im using in my shopping cart (VPASP) to pull the reviews into the product page. I want to also pull the tell a friend page in aswell.




<script language="javascript">
var xmlHttp

function showTellafriend(str)
{
if (str.length==0)
{
document.getElementById("tellafriend").innerHTML=""
return
}

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
return
}
var url="shoptellafriend.asp"
url=url+"?id="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("tellafriend").innerHTML=xmlHttp.responseText
}
}

function GetXmlHttpObject()
{
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}

showTellafriend("[catalogid]")
</script>

I can change the code and it pulls in the tell a friend fine, but i cant get it to do both, just one or the other.

What do I need to change in each section of javascript so they are unique and will both work together?

thanks in advance!