我在尝试访问 JavaScript 脚本中的函数时遇到问题,因此我可以根据选择的月份创建一组动态的可能日期。它甚至似乎根本无法访问 JavaScript 函数“populate()”。警报没有响应。我可能应该提到整个代码是从'include_once();'调用的 在另一个文件中。我尝试遵循以下示例:http ://www.youtube.com/watch?feature=player_embedded&v=UliJeDbc4cw
<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/但它每个月都有静态天数.
我只是好奇为什么我的不起作用,我无法弄清楚。
谢谢。