0
我在嘗試訪問JavaScript腳本內部的函數時遇到問題,因此我可以根據選擇的月份創建一組動態的可能日期。它甚至不會訪問JavaScript函數'populate()'。警報不響應。我應該提到這個完整的代碼是從'include_once();'在另一個文件中。我試圖按照從例如:http://www.youtube.com/watch?feature=player_embedded&v=UliJeDbc4cw動態日期選擇(Php/JS)
<script type="text/javascript">
function populate(month,day){
alert('Javascript Reached');
var month = document.getElementById('month');
var day = document.getElementById('day');
day.innerHTML="";
if (month.value == "Apr" ||
month.value == "Sep" ||
month.value == "Jun" ||
month.value == "Nov" ||
){
var limit = 30;
}
else if(month.value =="feb"){
var limit = 28;
}
else{
var limit = 31;
}
while(var temp < limit){
var newOption = document.createElement("option");
newOption.value = temp;
newOption.innerHTML = temp;
day.options.add(newOption);
temp++;
}
return true;
}
</script>
<?php
adminYearOption();
adminMonthOption();
adminDayOption();
function adminYearOption(){
echo "<select name='year'><option value=''></option>";
while($datecount < 50){
$currValue = (1980+$datecount);
echo "<option value='".$currValue."'>".$currValue."</option>";
$datecount++;
}
echo "</select>";
}
function adminMonthOption(){
?> <select id='month' name='month' onchange="return populate(this.id,'day')"><option value=''></option><?php
$time = strtotime("2013-01-01");
while($datecount < 12){
$currValue = date('M',$time);
echo "<option value='".$currValue."'>".$currValue."</option>";
$time = strtotime("+1 month", $time);
$datecount++;
}
echo "</select>";
}
function adminDayOption(){
echo "<select id='day' name='day'></select>";
}
?>
'
也爲想要創建動態的日期,這裏的任何其他閱讀器是一種替代方案: http://blog.elanman.com/2009/09/create-dynamic-date-selects/但它有天的靜態量爲每月。
我只是好奇爲什麼我沒有工作,我不知道。
謝謝。