rubo77

Untitled

Sep 30th, 2013
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.00 KB | None | 0 0
  1. <html><head>
  2. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script></head>
  3. <body>
  4. <a href="">restart</a><br>
  5. <?php
  6. if(!empty($_REQUEST)) {
  7.     echo sizeof($_REQUEST)." num request variables
  8.     <pre>";
  9.     var_export($_REQUEST);
  10.     echo "</pre>";
  11. }else {
  12.     ?><h1>visible post form 1</h1>
  13.     <form method="post" id="f" action=""><?
  14.         for($i=0;$i<10;$i++) echo '<input type="hiddden" value="v'.$i.'<a>" name="v'.$i.'">';
  15.         ?><input type="submit" name="sadosa">
  16.     </form>
  17.     <h1>hidden form 2</h1>
  18.     <form method="post" id="f2"><?
  19.         for($i=0;$i<10;$i++) echo '<input type="hidden" value="v'.$i.'&quot;a" name="v'.$i.'">';
  20.         ?><textarea name="bla">blubb</textarea>
  21. <select name="bla"><option>test</select>
  22. <input type="submit">
  23.     </form>
  24.     <h1>get form 1</h1>
  25.     <form method="get" id="g"><?
  26.         for($i=0;$i<10;$i++) echo '<input type="hidden" value="v'.$i.'" name="v'.$i.'">';
  27.         ?><input type="submit">
  28.     </form>
  29.     <?
  30. }
  31. ?>
  32.     <script>
  33.     // this disables all form elements and creates only one new element that contains all data serialized
  34.     $('form[method=post]').click(function() {
  35.         var data=$(this).serialize();
  36.         var num_form_elements=$(this).find('input, select, textarea').not('[type="submit"]').length;
  37.         var num_elements_already_disabled=$(this).find('input:disabled, select:disabled, textarea:disabled').length;
  38.         $(this).find('input, select, textarea').not('[type="submit"]').attr("disabled", true);
  39.         $(this).append('    <input type="hidden" name="num_form_elements" value="'+num_form_elements+'">');  // to mark request
  40.         $(this).append('    <input type="hidden" name="num_elements_already_disabled" value="'+num_elements_already_disabled+'">');  // to mark request
  41.         $(this).append('    <input type="hidden" name="serialized_hidden_data" value="'+data+'">');  // maybe .replace(/"/g,'&quot;')
  42.         // or use instead of a hidden input:
  43.         //$(this).append('  <textarea style="display:none" name="serialized_data">'+(data)+'</textarea>'); // maybe .replace(/</g,'&lt;')
  44.        
  45.     });
  46.     </script>
  47. </body></html><?
Advertisement
Add Comment
Please, Sign In to add comment