使用onclick输入的PHP值

使用onclick输入的PHP值,php,html,Php,Html,日历中有两个字段,输入的初始日期和当前日期,其中选择了日期。我只是不知道如何在用onclick选择后提取值 我通过POST尝试了id或名称,但它仍然不能与通常的输入一起工作,使用POST方法一切都很好 <form method="post"> <h3>Click on the date entry field to call the calendar.:</h3> <p> from the <input name="

日历中有两个字段,输入的初始日期和当前日期,其中选择了日期。我只是不知道如何在用onclick选择后提取值 我通过POST尝试了id或名称,但它仍然不能与通常的输入一起工作,使用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>

修复了所有语法错误:

<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>

您的文本输入元素不会出现在任何POST请求中,因为它们没有名称属性。给他们一个名称,然后再试一次。第一个输入缺少其name属性,因此无法发送到服务器。浏览器不会提交字段,除非它有一个属性,例如name=d1您也没有关闭您的窗口,您还有一个不匹配的

。好吧,您仍然没有关闭窗口,您的提交按钮有:form=myform,而您的表单没有任何名称或id。请阅读如何正确使用这些HTML元素,他们有什么属性以及这些属性的作用。即使这可能解决问题,一个好的答案包括解释你改变了什么以及为什么。仅仅发布一段代码而没有任何解释,甚至没有任何评论,这不是很有建设性的。什么解释?我写道,我没有使用onclick@Capricorn-该评论是为谁而写的,评论内容是什么?