javascript - How can I submit a form via POST? -


<form id="search" action="#" method="post" style="float: left">                   <div id="input" style="float: left; margin-left: 10px;" >         <input type="text" name="search-terms" id="search-terms" placeholder="search websites , categories..."  style="width: 300px;">     </div>     <div id="label" style="float: left; margin-right: 10px;">         <button type="submit" onclick="searchbox()" for="search-terms" id="search-label" class="glyphicon glyphicon-search"></button>     </div>  </form>  

when user clicks on div id label, want toggle display property of div input. working fine. have used following code implement functionality.

function searchbox(){     if ($("#input").css('display') == 'none') {          $('#input').css('display','block');      } else {          $('#input').css('display','none');     } } 

i want to submit form data via post functionality not working, neither pressing enter key nor when submit button clicked.

please me this.

try submitting through js

html

<form id="search" action="#" method="post">                   <div id="input" style="float: left; margin-left: 10px;" >         <input type="text" name="search-terms" id="search-terms" placeholder="search websites , categories..."  style="width: 300px;">     </div>     <div id="label" style="float: left; margin-right: 10px;">         <button type="submit"  for="search-terms" id="search-label" class="glyphicon glyphicon-search">click</button>     </div>  </form>  

js

$(".glyphicon").click(function(e){     e.preventdefault();           if ($("#input").css('display') == 'none') {                  $('#input').css('display','block');              } else {                  $('#input').css('display','none');             }              $( "#search" ).submit();          }); 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -