简体   繁体   English

从另一个输入类型设置输入类型 = 日期分钟 = 日期

[英]set the input type = date min from another input type = date

Hi i'm a rookie in html and been struggling in this inputs,嗨,我是 html 的菜鸟,一直在努力解决这个问题,

<label>Check-In Date :  </label>
<input id ="date1" type="date" name="from" min=<?php echo date('Y-m-d', strtotime("+3 days"));;?>>    
<label>Check-Out Date : </label>
<input id = "date2" type="date" name="to">

i just want to know how to set the second input minimum date from the first input selected value?我只想知道如何从第一个输入选定值设置第二个输入最小日期? i've already searched and i just can't get the right answer...我已经搜索过了,我只是无法得到正确的答案...

PHP is server-side script that only runs on the server (not on the client). PHP 是服务器端脚本,只在服务器上运行(不在客户端上)。 For a more detailed explanation of client-side vs server-side scripting please view this有关客户端与服务器端脚本的更详细说明,请查看


To accomplish what you want, you would use client-side script like JavaScript you can easily achieve this.为了完成你想要的,你可以使用像 JavaScript 这样的客户端脚本,你可以很容易地实现这一点。

Below is jQuery that will update the second field whenever the first field is changed.下面是 jQuery,它会在第一个字段更改时更新第二个字段。

jQuery jQuery

$("input[name='from']").change(function() {
  $("input[name='to']").val($(this).val());
})

Make sure to include jQuery so that the above loads: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>确保包含 jQuery 以便加载上述内容: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM