あなたが持っている最良の選択肢はAJAX
、値でリクエストを行うことだと思います。これにより、値を に送信して割り当てることができますPHP variables
。
それ以外の場合は、COOKIE
etc を使用して値を一時的に保存し、サーバー側の関数が次に呼び出されるたびにサーバー側で使用できます。
Ajax コード
<script type='text/javascript'>
function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (err2) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (err3) {
req = false;
}
}
}
return req;
}
var http = getXMLHTTPRequest();
function sendValue() {
var myurl = "session.php"; // to be present in the same folder
var myurl1 = myurl;
var value = document.getElementById('urDIV').value;
myRand = parseInt(Math.random()*999999999999999);
var modurl = myurl1+"?rand="+myRand+"url"+value ; // this will set the url to be sent
http.open("GET", modurl, true);
http.onreadystatechange = useHttpResponse;
http.send(null);
}
function useHttpResponse() {
if (http.readyState == 4) {
if(http.status == 200) {
var mytext = http.responseText;
// I dont think u will like to do any thing with the response
// Once you get the response, you are done.
}
}
else {
// don't do anything until any result is obtained
}
}
</script>
HTML 部分
// considering you are calling on a button call
<input type='button' onclick='sendValue();'>