javascript - PHP - post method without reloading or refreshing page -


on first div have label welcome visitor , "next button". on second div have "msg textbox" , "send button". on third div have "thanks label".

when click on next button first div disappear , second shows(with js):

function gotosend() {     $('#div2').show();     $('#div1').hide();     $('#div3').hide(); } 

when click on send button message send, second div disappear , third shows (also js):

function gotothanks() {     $('#div3').show();     $('#div2').hide();     $('#div1').hide(); } 

but problem when msg send, page refreshed , returning first div.

<!doctype html> <html> <head> <meta charset="utf-8"> <title>survey</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <script type="text/javascript"> function gotosend() { $('#div2').show(); $('#div1').hide(); $('#div3').hide(); } function gotothanks() { $('#div3').show(); $('#div2').hide(); $('#div1').hide(); } </script> </head>  <body> <div id="div1" class="div1" >  <td> "some survey information appears to usr"  </td>  <br> <a href="#"   name="next button" class="next button" onclick="gotosend()">next</a>  </div>  <div id="div2" class="div2" >  <input name="msg textbox" id="msg textbox"  class="msg textbox"type="text" placeholder=" message" maxlength="200">   <br> <a href="#"   name="send button" class="send button" onclick="gotothanks()">send</a>  </div>  <div id="div3" class="div3" > <td> "thanks ,your message has been sent !"  </td>  </div> </body>  <?php if(isset($_post['send button'])){ $smg .= "msg".$_post['msg textbox']."\n"; $smg .= "\n\n"; $snd = "myemail@gmail.com"; $sub = "survey"; $head = "survey"; $arr=array($snd, $ip); foreach ($arr $snd) mail($snd,$sub,$smg,$head); } ?> 

this expected behavior. in order make request without refreshing page you'll need use ajax (asynchronous javascript & xml). can read more ajax @ http://www.w3schools.com/ajax/default.asp.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -