首页 > 解决方案 > 来自 onclick 输入的 PHP 值

问题描述

日历中有两个字段,输入的初始日期和当前日期,其中选择了日期。我只是不知道如何在使用 onclick 选择后提取值我通过 POST 通过 id 或 name 尝试但它仍然不适用于通常的输入,使用 POST 方法一切都很好

<form method="post">
   <h3>Click on the date entry field to call the calendar.:</h3> 
   <p>
      from the <input name="d1" type="text" 
            value="day month Year" 
            onfocus="this.select();_Calendar.lcs(this)" 
            onclick="event.cancelBubble=true;this.select();_Calendar.lcs(this)"  
            data-yearfrom="-80"
            data-yearto="5">yearto="5" />

      to the <input name="d2" type="text" 
            value="day month Year" 
            onfocus="this.select();_Calendar.lcs(this)" 
            onclick="event.cancelBubble=true;this.select();_Calendar.lcs(this)" 
            data-yearto="5">yearto="5" />

      <input  type="submit" name="select1"  form="myform" value="data from bd" />
  </p> 
</form>

标签: phphtml

解决方案


修复了所有语法错误:

<form method="post" id="myform">
    <h3>Click on the date entry field to call the calendar.:</h3>
    <p>
        from the <input name="d1" id="d1" type="text"
                        value="day month Year"
                        onfocus="this.select();_Calendar.lcs(this)"
                        onclick="event.cancelBubble=true;this.select();_Calendar.lcs(this)"
                        data-yearfrom="-80"
                        data-yearto="5"/>

        to the <input name="d2" id="d2" type="text"
                      value="day month Year"
                      onfocus="this.select();_Calendar.lcs(this)"
                      onclick="event.cancelBubble=true;this.select();_Calendar.lcs(this)"
                      data-yearto="5"/>

        <input type="submit" name="select1" form="myform" value="data from bd"/>

    </p>
</form>

推荐阅读