Advertisement
hadrianmh

index

May 2nd, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3. <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script>
  4. <script type="text/javascript" src="https://raw.githubusercontent.com/carhartl/jquery-cookie/master/src/jquery.cookie.js"></script>
  5. <script>
  6. $(document).ready(function(){
  7.   $("#submit").click(function(){
  8.       var kode = $("#kode").val();
  9.       $.ajax({
  10.           type: "POST",
  11.           url: "proses.php",
  12.           data: "kode="+kode,
  13.           success: function(msg){
  14.               $("#hasil").show();
  15.               $("#hasil").html(msg);
  16.               var cokis = $.cookie("hasilnya");
  17.               if(cokis != "undefined"){
  18.                $("#selectbox option[value='"+cokis+"']").attr("selected", "selected");
  19.               }
  20.               $("#selectbox").on("change", function(){
  21.                var hasilselect = $(this).val();
  22.                $.removeCookie("hasilnya");
  23.                $.cookie("hasilnya", hasilselect, {expires: 365, path: '/'});
  24.             });
  25.            }
  26.            
  27.         });
  28.    });
  29. });
  30. </script>
  31. </head>
  32. <body>
  33. <form>
  34. <input id='kode' type='text' placeholder='Enter text ..'></input>
  35. <input type='button' id='submit' value='submit'/>
  36. <div id='hasil' ></div>
  37. </form>
  38. </body>
  39. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement