I want to pass a value from one page to other page when the user clicks on a link.
For example
<a href="javascript:void(0)" onclick="window.parent.loadFrame('bloodbankFacilities/specialtyDataTable.php',this.innerHTML);">Blood Bank Facilities </a>
above is the the link i have to redirect the user to specialityDataTable.php
I want to pass a text value to specialityDataTable.php when the user clicks the link and get the value in specialityDataTable.php by using php GET method and echo it.
I was doing this before, but i forgot how to do it :( .
function loadFrame(url,anchorText){
//alert(url);
if(document.getElementById(url)){
if(hasClassName(document.getElementById(url),"selectedTabHead")){
return false;
}
else{
changeTab(url,document.getElementById(url));
return false;
}
}
iframeId = "ifr_"+url;
var iframeElem = getElementsByClass("bodyFrame");
for(var i=0;i<iframeElem.length;i++){
iframeElem[i].style.display = 'none';
}
if(!document.getElementById(iframeId)){
var elt = document.createElement("iframe");
elt.setAttribute("class","bodyFrame");
elt.setAttribute("id",iframeId);
elt.setAttribute("onload","iframeReload();");
document.getElementById('content').appendChild(elt);
}
document.getElementById("loadr").style.display = 'block';
document.getElementById(iframeId).style.display = 'block'
document.getElementById(iframeId).src = url;
var elements = getElementsByClass("tabHead",document.getElementById("tabStrip"));
for(var i=0;i<elements.length;i++){
if(hasClassName(elements[i],"selectedTabHead")){
removeClassName(elements[i],"selectedTabHead");
}
}
var elt = document.createElement("span");
elt.setAttribute("class","tabHead selectedTabHead");
elt.setAttribute("id",url);
elt.innerHTML = "<a href='javascript:void(0);' onclick=changeTab('"+url+"',this.parentNode)>"+anchorText+"</a> <b onclick='removeTab(this.parentNode.id)'>x</b>";
if(elements.length == 0){
document.getElementById("tabStrip").appendChild(elt);
}
else{
document.getElementById("tabStrip").insertBefore(elt,elements[0]);
}
var tabCookie = document.getElementById("tabStrip").innerHTML;
setCookie("<?php echo $_SESSION['userId'] ?>",tabCookie);
setWidth();
//autoHeight();
};
function loadFullScreen(url){
url = "<?php echo ROOT_PATH; ?>"+"full.php?q="+url;
jsPopUp(url,800,1000);
}
function changeTab(url,obj){
// document.getElementById("loadr").style.display = 'block'; 开发者_如何学编程
parentnode = document.getElementById("tabStrip");
var elements = getElementsByClass("tabHead",parentnode);
for(var i=0;i<elements.length;i++){
if(hasClassName(elements[i],"selectedTabHead")){
removeClassName(elements[i],"selectedTabHead");
}
}
addClassName(obj,"selectedTabHead");
// document.getElementById("bodyFrame").src = url;
iframeId = "ifr_"+url;
var iframeElem = getElementsByClass("bodyFrame");
for(var i=0;i<iframeElem.length;i++){
iframeElem[i].style.display = 'none';
}
//alert(document.getElementById(iframeId));
if(!document.getElementById(iframeId)){
var elt = document.createElement("iframe");
elt.setAttribute("class","bodyFrame");
elt.setAttribute("id",iframeId);
elt.setAttribute("onload","iframeReload();");
document.getElementById('content').appendChild(elt);
}
document.getElementById(iframeId).style.display = 'block'
};
Well this just means you have to add the variable to the url..
bloodbankFacilities/specialtyDataTable.php?variable=value
You can pass values with get method using jquery or ajax or simple link tag and then you can get values via php also with many ways like file_get_contents or session variable or storing in db.
精彩评论