rootmath
01-06-2011, 04:36 AM
Hi, I want to change a title div and a video div when I click on a single link. Right now I have one function that takes two parameters. The parameters are 2 separate txt files that contain the new divs. I want to replace the old divs with the txt files but it only works for the second function. I've searched everywhere but can't find a clear answer. Any help is very much appreciated!
Thanks,
M.
link:
<a href="" onClick="loadChangeVideo('video1', 'title1');titleSwitch('title1')return false">
javascript:
<script language="javascript">
var videoName;
var videoTitle;
function loadChangeVideo(videoName, videoTitle)
{
function(videoName){
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("video_title").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET", videoTitle + ".txt" ,true);
xmlhttp.send();
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("switch_video").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET", videoName + ".txt" ,true);
xmlhttp.send();
this.videoName = "videoName";
window.location.hash = videoName;
}
}
</script>
Thanks,
M.
link:
<a href="" onClick="loadChangeVideo('video1', 'title1');titleSwitch('title1')return false">
javascript:
<script language="javascript">
var videoName;
var videoTitle;
function loadChangeVideo(videoName, videoTitle)
{
function(videoName){
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("video_title").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET", videoTitle + ".txt" ,true);
xmlhttp.send();
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("switch_video").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET", videoName + ".txt" ,true);
xmlhttp.send();
this.videoName = "videoName";
window.location.hash = videoName;
}
}
</script>