我有一个这样的 HTML 选择标签:
<select name="since_date">
<option value="<?php $sixmonths = date('Y-m-d', strtotime('-6 months')); echo $sixmonths; ?>">6 months</option>
<option value="<?php $fivemonths = date('Y-m-d', strtotime('-5 months')); echo $fivemonths; ?>">5 months</option>
<option value="<?php $fourmonths = date('Y-m-d', strtotime('-4 months')); echo $fourmonths; ?>">4 months</option>
<option value="<?php $threemonths = date('Y-m-d', strtotime('-3 months')); echo $threemonths; ?>">3 months</option>
<option value="<?php $twomonths = date('Y-m-d', strtotime('-2 months')); echo $twomonths; ?>">2 months</option>
<option value="<?php $onemonth = date('Y-m-d', strtotime('-1 month')); echo $onemonth; ?>">1 month</option>
</select>
我希望在选择例如 4 个月时出现一个新的选择标签,如下所示:
<select name="until_date_4months">
<option value="<?php $threemonths = date('Y-m-d', strtotime('-3 months')); echo $threemonths; ?>">3 months</option>
<option value="<?php $twomonths = date('Y-m-d', strtotime('-2 months')); echo $twomonths; ?>">2 months</option>
<option value="<?php $onemonth = date('Y-m-d', strtotime('-1 month')); echo $onemonth; ?>">1 month</option>
<option value="<?php $now = date('Y-m-d'); echo $now; ?>">Now</option>
</select>
每次选择一个时期(例如 6 个月、5 个月)时,必须出现一个新的选择,其中的选项低于所选的选项加上一个新的选项“现在”,如上所示。这怎么可能?方法是什么?我想通过提交按钮使用这些信息。(使用 JQuery 向特定 PHP 文件发送 GET 请求<-我知道如何处理)。例如,我可以像这样使用 JavaScript:
function sinceDateValue(selection) {
if (selection.value == "<?php $fourmonths = date('Y-m-d', strtotime('-4 months')); echo $fourmonths; ?>") {
document.getElementbyId(until_date_4months).style.display = "block"
}
}
并用于第二次提交id="until_date_4months"
和style="display: none;"
. 同样对于第一次提交onchange="testValue(this);
,但这只会显示提交,我只想使用表单发送两个信息:since_date 和 until_date...