how to pass php value from one div to another div within same page
how to pass php value from one div to another div within same page
Collapse
X
-
It appears you are asking how to move something after the page has been streamed out from the web server to the client computer.
If that is the case, that cannot be done with php. php does not execute on the client computer, you have to use javaScript to do that.
And if that is your question there are several ways to do that. Here is one example not necessarily the best, but it demonstrates what I think your question is.
Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script type="text/javascript"> <!-- function moveContentTo2() { document.getElementById("div2").innerHTML = document.getElementById("div1").innerHTML; document.getElementById("div1").innerHTML = ''; } function moveContentTo1() { document.getElementById("div1").innerHTML = document.getElementById("div2").innerHTML; document.getElementById("div2").innerHTML = ''; } //--> </script> </head> <body> The value in div 1 is <div id="div1">Move this text</div> The value in div 2 is <div id="div2"></div> <input type="button" value="Move content to div 2" onclick="moveContentTo2()"> <input type="button" value="Move content back to div 1" onclick="moveContentTo1()"> </body> </html>
Comment