Hi everyone, I have been trying to find an answer to this, searching all over the web, but no luck. I have created a very simple test page to show what I mean and hopefully someone can explain what I need to do to make this work. Simply put, I have a page that has an onclick href that sends information to a DIV on the page. I wish to simply have this redirect to another page, but instead it shows the response.redirect inside the DIV. How do I get it to redirect from within the DIV to a whole new web page? Here is the code:
The main page: formpage.asp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Testing...</title>
<script src="scripts.js"></script>
</head>
<body>
<table><tr><td>
<a href="#null" onclick="calculate()"/>sho
w result</a>
</td>
<td>
</td></tr></table>
<div id="resultssection" style="display:none;"></di
v>
</body>
</html>
The script.js file:
var xmlHttp
function calculate()
{
xmlHttp=GetXmlHttpObject()
;
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="formpageshowgoodies.a
sp";
xmlHttp.onreadystatechange
=stateChan
ged;
xmlHttp.open("GET",url,tru
e);
showHide();
xmlHttp.send(null);
}
function showHide()
{
if (document.getElementById("
resultssec
tion").sty
le.display
== 'none')
{
document.getElementById("r
esultssect
ion").styl
e.display = '';
}
else
{
document.getElementById("r
esultssect
ion").styl
e.display = 'none';
}
}
function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("r
esultssect
ion").inne
rHTML=xmlH
ttp.respon
seText;
document.getElementById("r
esultssect
ion").styl
e.display = '';
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLH
TTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.X
MLHTTP");
}
}
return xmlHttp;
}
The formpageshowgoodies.asp page:
<%response.redirect "formpage2.asp"%>
Can someone show a simple way to do this? I know the above looks like it's not required to use ajax, but what I am trying to do is more complex (mutiple onclick events, divs, etc) - I've just simplified it here to get the idea across.