我的下拉菜单选择日期不起作用,除非我按住鼠标左键单击。 只有年份下拉工作正常,但只有按住鼠标按钮才能使用月份和日期。
以下是它的网站:www.cipslimoshuttle.com/tickets
以下是代码:
<label>
Date of travel:
<select name="ticketYear">
<?php
$i = date('Y');
while($i <= date('Y')+5){
?>
<option <?php if(date('Y') == $i) echo 'selected' ?> value="<?php echo $i ?>"><?php echo $i ?></option>
<?php
$i++;
}
?>
</select>
<select name="ticketDay">
<?php
$i = 1;
while($i <= 31){
?>
<option <?php if(date('j') == $i) echo 'selected' ?> value="<?php echo $i ?>"><?php echo $i ?></option>
<?php
$i++;
}
?>
</select>
<select name="ticketMonth">
<?php
$months = array(
'01-January',
'02-February',
'03-March',
'04-April',
'05-May',
'06-June',
'07-July',
'08-August',
'09-September',
'10-October',
'11-November',
'12-December'
);
foreach($months as $month) {
$month = explode('-',$month);
?>
<option <?php if(date('m') == $month[0]) echo 'selected' ?> value="<?php echo $month[0] ?>"><?php echo $month[1] ?></option>
<?php
}
?>
</select>
</label>
答案 0 :(得分:0)
问题在于您的标签标签您需要在选择框之前结束。检查它是否可行
<label>
Date of travel: </label>
<select name="ticketYear">
<?php
$i = date('Y');
while($i <= date('Y')+5){
?>
<option <?php if(date('Y') == $i) echo 'selected' ?> value="<?php echo $i ?>"><?php echo $i ?></option>
<?php
$i++;
}
?>
</select>
<select name="ticketDay">
<?php
$i = 1;
while($i <= 31){
?>
<option <?php if(date('j') == $i) echo 'selected' ?> value="<?php echo $i ?>"><?php echo $i ?></option>
<?php
$i++;
}
?>
</select>
<select name="ticketMonth">
<?php
$months = array(
'01-January',
'02-February',
'03-March',
'04-April',
'05-May',
'06-June',
'07-July',
'08-August',
'09-September',
'10-October',
'11-November',
'12-December'
);
foreach($months as $month) {
$month = explode('-',$month);
?>
<option <?php if(date('m') == $month[0]) echo 'selected' ?> value="<?php echo $month[0] ?>"><?php echo $month[1] ?></option>
<?php
}
?>
</select>