2017-03-07 38 views
0
.bind('dpClosed',function(e, selectedDates) { 
     console.log('You closed the date picker and the ' // wrap 
      + 'currently selected dates are:'); 
     console.log(selectedDates); 
     var ll=document.getElementById('ll'); 
         ll.value=selectedDates; 

    } 
); 

我想通過selectedDates變量到PHP變量如何通過multselected JS變量值PHP變量

+0

請妥善你要什麼做格式化代碼 –

+0

分配值後的「php變量」? –

回答

0

只有這樣,才能傳遞變量值從前臺到服務器端或者是提交表單或使用AJAX。

因爲這兩個運行在不同的地方,如果你有一個頁面,你不能分配一個js變量到php,因爲php運行在服務器上,並且它已經在頁面加載之前跑了路。

你必須使用AJAX或表單提交本:

$.post('the/url/to/post', {selectedDates:selectedDates}, function(response){ 
    console.log(response); 
}); 

現在在PHP中可以用得到它:

$_POST['selectedDates']