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

    打赏 评论

相关推荐 更多相似问题