10/10/2018, 11:06
Làm sao gán biến javascrip cho biến php ?
mình chỉ biết gán biến php cho javascipt thôi:
alert <?php echo $bienPHP ?>
Nhưng gán biến javascript cho biến php thì phải làm thế nào?
Mong mọi người giúp đỡ. Cảm ơn !
alert <?php echo $bienPHP ?>
Nhưng gán biến javascript cho biến php thì phải làm thế nào?
Mong mọi người giúp đỡ. Cảm ơn !
Bài liên quan





<script type="text/javascript"> width = screen.width; height = screen.height; if (width > 0 && height >0) { window.location.href = "http://maychu.net/test.php?width=" + width + "&height=" + height; } else exit(); </script>Mong được giúp đỡ. Cảm ơn !
Thân.
[x]
<script type="text/javascript"> function echoText(str) { var xmlhttp; if (str.length==0) { document.getElementById("txtarea").innerHTML=""; return; } 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("txtarea").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","action.php?param="+str,true); xmlhttp.send(); } </script> <form> <!--//(to be filled with yours)//--> <input type="button" onClick="javascript:echoText('demo');" value="show demo"> </form> <div id="txtarea"></div><?php $your_variable = $_GET["param"]; if(!empty($your_variable)){ echo $your_variable; } else { echo "nothing to be shown here"; } ?>[x]
Mình đang làm cái trang đăng kí tín chỉ, khi đăng kí tín chỉ, sẽ có môn học để mình đăng kí, nhứng trong những môn đó mình có thể học vượt rồi, nên khi click vào chexbox thì sẽ báo là "bạn đã học môn này".....
//.js file $('input[type=checkbox]').click(function (){ var seft = this; $.ajax({ url: 'path/to/php/file', type: 'POST', data: {cbVal: $(seft).val()},//giá trị của checkbox được kích sendBefore: function () { //hiện chữ loadding... chẳng hạn $('#busy').text('Loading...'); }, success: function (respon){ eval('var stt = '+respon+';'); if(! stt.status){//nếu đăng ký rồi alert(stt.msg);//thông báo $(seft).attr('checked', false);//unchecked giá trị checkbox } } }); }); //.php file $cbVal = $_POST['cbVal']; //giá trị post //check giá trị so với csdl if (){//đăng ký rồi $out = array( 'status' => false, 'msg' => 'Đăng ký rồi' ); } else { //chưa đăng ký $out = array( 'status' => true, 'msg' => 'chưa đăng ký' ); } echo json_encode($out);cảm ơn "1024KB" nhiều, nhưng anh có thể làm cụ thể được không? như "maychu.net" làm 2 file rõ.
Chân thành cảm ơn mọi người góp ý. Mong được chỉ thêm để e làm được bài này.