|  | Posted by Pasquale on 09/08/05 06:32 
Snippets of code below...
 I have created a registration system which allows athletes to register
 for more than one event at a time. There is a details page where they
 can choose different merchandise for each event and their totals are
 dynamically updated accordingly, as well as their grand total. I have
 created blank hidden fields to be used for the JavaScript calculations
 and to POST the totals with PHP. Before the details page there is a
 personal information page and the selected events, and I would like to
 carry that information through this process using sessions. However,
 when I use sessions the hidden field values that are dynamically, and I
 guess virtually, filled in with JavaScript POST their initial blank
 value instead of the calculated totals. Without sessions they POST fine.
 
 Is there a way to use sessions this way?
 
 For now I am going to try POSTing the information to an interim page
 with all the hidden fields I need and they will have their initial value
 and then redirect to the next page, which is where I will start my session.
 
 Thanks.
 
 details page...
 
 #at the top
 session_start();
 header("Cache-control: private");
 
 $fname = isset($_POST['fname'])?$_POST['fname']:$_SESSION['fname'];
 $lname = isset($_POST['lname'])?$_POST['lname']:$_SESSION['lname'];
 
 $_SESSION['fname'] = $fname;
 $_SESSION['lname'] = $lname;
 
 
 
 <snip>
 JavaScript
 
 <!--Begin
 function GrandTotalCal () {
 var gtotalowing = 0;
 var seidsfld = document.forms[0].elements['regsubevtarrayfld'];
 var subevtarray = seidsfld.value.split(",");
 for (i = 0; i < subevtarray.length; i++) {
 var setotalhdn = "se"+subevtarray[i]+"totalhdn";
 gtotalowing += parseInt(document.forms[0].elements[setotalhdn].value);
 }
 document.getElementById('gtotalcost').innerHTML = '$' + gtotalowing +
 '.00';
 document.forms[0].elements['gtotalhdn'].value = gtotalowing;
 }
 //--End-->
 
 
 HTML
 
 <SPAN id="gtotalcost" class="prices">0</SPAN>
 <INPUT type="hidden" name="gtotalhdn" value="" />
 
 </snip>
 
 top of next page...
 <snip>
 
 session_start();
 header("Cache-control: private");
 
 $gtotalhdn =
 isset($_POST['gtotalhdn'])?$_POST['gtotalhdn']:$_SESSION['gtotalhdn'];
 
 $_SESSION['gtotalhdn'] = $gtotalhdn;
 
 </snip>
  Navigation: [Reply to this message] |