I have a website (verlager.com) with a form that calls a PHP script, "foo". After running "foo"; the PHP script loads the pairing module. The big problem is that, on returning to index.php, the fee data is gone from the form.
Usually, I hold the tab key and get most of the data back. Except the problem is the "fee" field. That is literal. Not a lookup or calculation. But we need it!
Demo: http://verlager.com Click folder icon to load player list. Press and hold {tab} to fill in player's data. Double click on a fee column input field. Enter 25 which is our annual membership fee.
Click "done!" The pairing list loads with the player's names in little moveable boxes. Now return to the previous page with the browser back button. The form's fee input data is now gone! And holding the {tab} key brings back the other data but not the fee data.
As I understand it, it will be necessary to use a PHP session to store the fee data. Can the PHP script "foo" save a session data?
Should I instead use PHP to generate a JSON file with player_name and fee? I would prefer (for educational purposes) to use PHP sessions.
HTML
<div class="universal" ><div class="role">1.</div><div class="item ui-widget"> <input type = "text" id = "P1" onblur="calcEntryFee(this);" maxlength = "21" name = "N1" class = "autocomplete-2 text person" /></div> <div class="item EF"> <input type = "text" onblur="findTotalEF();" name = "ef-fee" maxlength = "1" size = "1" id = "E1" /></div> <input type="checkbox" onchange="findTotalEF();" class="item late pip" tabindex="-1" id="C1" /> <div class="item EXP"><input type = "text" onblur="getExpireDate();" class="CCCRexpDate" name = "cccr_exp" maxlength = "10" size = "10" id = "CCCR_X1" disabled /> </div> <div class="item MEM" title = "double click to add mem. pmt." onclick="$('#M1').removeAttr('disabled')"> <input type = "text" onblur="calcEntryFee(this);findTotalMem();findTotalEF(); " name = "mem-fee" class="numbers fee fee_amt" maxlength = "2" size = "2" id = "M1" disabled /></div> <div class="pure-u-1-12 RANK"> <input type = "text" onblur="getClass();" class="number" maxlength = "4" size = "4" id = "Y1" disabled /></div> <div class="item USCF"><input type = "text" onblur="getUSCFexpireDate();" class="USCFexpDate" name = "uscf_exp" maxlength = "4" size = "5" id = "USCF_X1" disabled /></div> </div>
PHP
<?php // "foo" ini_set('display_errors', 1); error_reporting(~0); $myfile = fopen("players.txt", "w") or die("Unable to open file!"); $x = 0; $max_entrants = 48; for ($i = 1; $i <= $max_entrants; $i++) { $tmp = "one, two"; $x = $i; if (!empty($tmp)) { $zed = trim($tmp," "); if (strpos($zed, ', ') !== false) { fwrite($myfile, $zed ."|"); } } } fclose($myfile); if (filesize("players.txt")) {header('Location: ../pairing.php');} else {header('Location: ../index.php');}
1 Answers
Answers 1
There is some package out there that you can download to achieve this purpose .It has been a nominee for the innovation awards organized by phpclasses.org and the comment of nomination is:
Sometimes users of an application need to enter a lot of information in a form.
If for some reason, like for instance power or connectivity interruption, they do not submit the form before finishing entering all the information, they may lose the work done previously to enter part of the information.
This class provides a solution to prevent that users lose values entered in form fields by saving draft values to browser storage that can be recovered later.
Manuel Lemos
you can find this package PHP AutoSave Form Draft: Save form input values in browser storage as draft .It is written in PHP but use JavaScript to achieve this goal...
0 comments:
Post a Comment