douqiong8412 2014-04-25 13:00
浏览 40
已采纳

从使用jquery隐藏的表单发布数据

I have a form that I had hidden using jquery which on click is displayed.I want to post data using php but on clicking submit nothing happens.see code

 <div class="col-12 col-sm-2 with-click-text">
<form name="contactform" method="post" action="">
<table class="click-text font-light "width="450px"  >
<tr>
<td>
  <label for="first_name">First Name *</label> 
 <input  type="text" name="first_name" maxlength="50" size="30">
 <label for="last_name">Last Name *</label> 
 <td valign="top">  <input  type="text" name="last_name" maxlength="50" size="30"> 
  <label for="email">Email Address *</label>
  <input  type="text" name="email" maxlength="80" size="30" required> 
  <label for="telephone">Telephone Number</label>
   <input  type="text" name="telephone" maxlength="30" size="30"> 
  <label for="comments">Comments *</label>
  <textarea  name="comments" maxlength="1000" cols="25" rows="6" required></textarea> 
   <input type="submit" name="mailit" id="submit" value="Submit"> 
  </form>
</td>
</tr>
</table>
</div>

if(isset($_POST['mailit'])) { echo"do something";}

  $('.with-click-text').click(
    function(e) {
$(this).css('overflow', 'visible');
            $(this).find('.click-text')
                .show()
                .css('opacity', 0)
                .delay(200)
                .animate(
                    {
                        paddingTop: '25px',
                        opacity: 1
                    },
                    'fast',
                    'linear'
                );

    $("#submit").on("click",function(e){
    $(this).submit();

            });
            });
  • 写回答

1条回答 默认 最新

  • dongyan9838 2014-04-25 13:09
    关注

    You have no element with id submit. Update your function;

    ....
    $("input[type='submit']").on("click",function(){
        event.preventDefault();
        $(this).submit();
    
    });
    

    You can see demo here: Demo

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料