donglang6656 2016-11-22 14:31
浏览 24

第二个下拉列表基于第一个下拉列表,只有php和html

I've a dropdown list Year made in php with years from current year until current year+10:

<p>Year:
        <select name="sel_year">
<?php
    $year=date("Y")-1;
    for ($i = 0; $i <= 10; $i++) 
    {   
        $year = $year+1;
        echo("<option value=\"$year\">$year</option>");
    } 
?>      
    </select>

And i want to make a second dropdown list with months that are based on the selection made on the previous list (Year), the thing is that i can only use html and php and i need to do this on the same page and, if possible, without using a submit button. This is what i've so far:

<p>Month:
    <select name="sel_month">
<?php
    if(sel_year==(date("Y")))
    {
        for ($month = date("m"); $month <= 12; $month++) 
        {       
            $monthName = date('F', mktime(0, 0, 0, $month, 10));
            echo("<option value=\"$month\">$monthName</option>");
        }   
    }
?>      
    </select>

In this part I only want to allow to user to select the months from now until December (inclusive) if the selected year previously is the same year as we're in. Any ideas?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?