This code will create a 16 digit code used for guid’s. It will set this when page loads into a textbox, and will also send this in the GET string.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> <form action="passvar.php" method="get" onsubmit="return guid()" name="PIQuote"> <script> function s4() { return Math.floor((1 + Math.random()) * 0x10000) .toString(16) .substring(1); }; function guid() { return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); } var uuid = guid(); </script> <script> $(document).ready(function(){ $('#myguid').val(uuid); //transfer a javascript variable to textbox }); </script> <input type="hidden" name="theguid" id="myguid"> <input type="submit"> </form> |
and to read a value from the textbox
1 2 3 |
var textboxvalue = $("#myguid").val() |