Python, problem passing list between cgi pages

I have a function confirmpurchase() which produces a table - no problem. I attach an image of the table. At the bottom of the table there is a button which should pass the value of the variable mylist to an action page Pay_Receipt.cgi.

PROBLEM
the value of mylist is not being passed to the action page Pay_Receipt.cgi - which only produces the following output

hello this is pay receipt [ this is value of mylist its done

I know  that the value of mylist is available just before confirmpurchase() is executed. You will see the value of an example 'mylist' highlighed in the test text just above the table (typical value of mylist is ['450738', [10, 11, 12], [10, 11, 12, 13, 15], [10, 11]].  I therefore conclude that I have a problem with the syntax used with the bottom left button on the table - or with the syntax within the action page.

I am attaching  the code for the page which includes the function confirmpurchase() function -  (lines 259 - 388) for the function definition and line 587 for the deployment of the function. Also attached  is the code for the action page.

Hopefully the syntax problem will be obvious.

Thank you for any help possible

James

TABLE PRINTOUT
ACTION PAGE
#!C:\Python34\python.exe
import cgi,cgitb
import mysql.connector as conn
import collections
import datetime
def htmlTop():
    print("""Content-type:text/html\n\n
        <!DOCTYPE html>
        <html lang="en">
            <head>
                <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
                <title> My Server-side template</title>
        </head>
        <body>""")

def htmlTail():
    print(""" its done</body>
        </html>""")

def getData():
    formData = cgi.FieldStorage()
    mylist = formData.getlist('mylist')
    return mylist


def connectDB():
    db=conn.connect(host='localhost' ,user='root' ,passwd='844cheminduplan' ,db='office')
    cursor = db.cursor()
    return db, cursor 

def UpdateInfo2(db,cursor):
    cursor.execute ("""
       UPDATE registrations
       SET  T1ytdlatest='{0}', T2ytdlatest='{1}', T3ytdlatest='{2}'
       WHERE memberID={3}
    """.format(mylist[1], mylist[2], mylist[3],mylist[0]))
    db.commit()
    db.close 
    
def UpdateInfo1(db,cursor):#see note at bottom of page  on use of mylist_DUPLICATE
    cursor.execute ("""
       UPDATE registrations
       SET  T1ytd='{0}', T2ytd='{1}', T3ytd='{2}'
       WHERE memberID={3}
    """.format(mylist_DUPLICATE[1], mylist_DUPLICATE[2], mylist_DUPLICATE[3],mylist_DUPLICATE[0]))
    db.commit()
    db.close
    
#main program
if __name__== "__main__":
    try:
        htmlTop()
        print("hello this is pay receipt")
        db,cursor=connectDB()
        
        form = cgi.FieldStorage() 
        
        mylist = form.getvalue('mylist')
        
                
        
        print(mylist, "this is value of mylist")        
        
        
        
        htmlTail()
    except:
        cgi.print_exception()

Open in new window


THE PAGE WHICH CONTAINS   confirmpurchase()
#!C:\Python34\python.exe
import collections
import cgi
import cgitb
import mysql.connector as conn
import datetime
def htmlTop():
    print("""Content-type:text/html\n\n
        <!DOCTYPE html>
        <html lang="en">
            <head>
                <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
                <title> My Server-side template</title>
        <style type='text/css'>
         
       
    
        #container {
                position:absolute;
                left:50%;
                top:50%;
                width:909px;
                height:500px;
                margin-left: -454px;
                margin-top: -250px;
                z-index:1;
                background-color: #D9F2F0;
                text-align:center;
        }
        
       
        
        </style>

        <script type='text/javascript' src='js/jquery.js'></script> <!--//this is the jquery magic-->
        <script type='text/javascript'> //this is the jquery plugin for aligning the image vertically
            $(window).load(function(){
                /*we are using $(window).load() here because we want the coding to take
                effect when the image is loaded. */
                
                //get the width of the parent
                var parent_height = $('#the_image').parent().height();
                var image_height = $('#the_image').height();
                
                var top_margin = (parent_height - image_height)/2;
                
                //center it
                $('#the_image').css( 'margin-top' , top_margin);
            });
        </script>


            </head>
    <body>""")

def htmlTail():
    print(""" its done</body>
        </html>""")

def connectDB():
    db=conn.connect(host='localhost' ,user='root' ,passwd='844cheminduplan' ,db='office')
    cursor = db.cursor()
    return db, cursor 
    

def getData():
    formData = cgi.FieldStorage()
    #selection = formData.getlist('selection')
    selection = formData.getlist('selection')
    selectionTWO = formData.getlist('selectionTWO')
    selectionTHREE = formData.getlist('selectionTHREE')
    memberID = formData.getlist('memberID')
    return selection,selectionTWO,selectionTHREE,memberID

# This function below is to select the T1ytd, T2ytd and T3ytd values from table registations. These are
# are to be used with the T1ytdlatest, T2ytdlatest, T3ytdlatest values to determine the delta
# purchases and also the revised values for T1ytd.... etc

def SelectfromDB(db,cursor):
    cursor.execute("""select T1ytd,T2ytd,T3ytd,ALPAID_ytd from registrations WHERE memberID = "%s" """
    %(memberID)) 
    order_ytd=cursor.fetchall()
    return order_ytd 




def killcommasselection(selection):
    newlist =[]
    for m in selection:
        MC= int(m[:])
        newlist.append(MC)
        selection = newlist
    return selection



def killcommasselectionTHREE(selectionTHREE):
    newlist =[]
    for m in selectionTHREE:
        MC= int(m[:])
        newlist.append(MC)
        selectionTHREE = newlist
    return selectionTHREE



def killcommasselectionTWO(selectionTWO):
    newlist =[]
    for m in selectionTWO:
        MC= int(m[:])
        newlist.append(MC)
        selectionTWO = newlist
    return selectionTWO


    

    

#-------------------------------------------------------------------------------------------------------------------    
# NOTE on the following two update functions.  UpdateInfo2 updates the columns T1ytdlatest,  T2ytdlatest, T3ytdlatest 
#wheras UpdateInfo1 updates T1ytd, T2ytd and T3ytd. Remember how this wworks  - the very first  update to Registrations
# is to the ytdlatest columns. Immediately after that the delta order and ytd orders and receipts are done by netting 
# together the values of ytd and tydlates columns. Initially for the first order the ytd colums are blank []'s.
# AFTER THE RECEIPT AND MEMBER STATUS ARE UPDATED - THEN - UpdateInfo1 is run to update ytd columns. At this moment 
#the ytd and ytdlatest columns are the same values.

#On the next update cycle, as for the first, the ytdlatest columns are updated first. Then the delta calculations are done
#for the recipts and after that, the ytd columns are updated.

# NOTE ALSO that mylist contains all the informaton for updating.

# Note on  structure of the update function.  The SET and WHERE lines use '{0}', '{1}', '{2}', '{3}' - think of these
# as buckets. We define the content of the buckets via the .format line. In this line we select the values to be stored
# in the buckets. The .format values need to be lined up with the names given to the {}'s. So for example mylist[0] must 
#be the last one of the format string as it needs to corrospond with the last item in the SET/WHERE lines above.
    
def UpdateInfo2(db,cursor):
    cursor.execute ("""
       UPDATE registrations
       SET  T1ytdlatest='{0}', T2ytdlatest='{1}', T3ytdlatest='{2}'
       WHERE memberID={3}
    """.format(mylist[1], mylist[2], mylist[3],mylist[0]))
    db.commit()
    db.close 
    
def UpdateInfo1(db,cursor):#see note at bottom of page  on use of mylist_DUPLICATE
    cursor.execute ("""
       UPDATE registrations
       SET  T1ytd='{0}', T2ytd='{1}', T3ytd='{2}'
       WHERE memberID={3}
    """.format(mylist_DUPLICATE[1], mylist_DUPLICATE[2], mylist_DUPLICATE[3],mylist_DUPLICATE[0]))
    db.commit()
    db.close
    
def UpdateEnrolStatus(db,cursor): # to flag that member has paid enrollement fee
    db,cursor=connectDB()
    cursor.execute ("""
        UPDATE registrations
        SET  Enrol_Status='{0}' 
        WHERE memberID={1}
    """.format(1, mylist_DUPLICATE[0]))
    db.commit()
    db.close    
#-----------------------------------------------------------------------------------------------------

def deltacalculate (T1ytd,T2ytd,T3ytd,T1ytdlatest,T2ytdlatest,T3ytdlatest):
    T1delta_dropped=[x for x in T1ytd if not x in T1ytdlatest]
    T1delta_nochange=[x for x in T1ytd if x in T1ytdlatest]
    T1delta_added=[x for x in T1ytdlatest if not x in T1ytd]
    
    T2delta_dropped=[x for x in T2ytd if not x in T2ytdlatest]
    T2delta_nochange=[x for x in T2ytd if x in T2ytdlatest]
    T2delta_added=[x for x in T2ytdlatest if not x in T2ytd]
    
    T3delta_dropped=[x for x in T3ytd if not x in T3ytdlatest]
    T3delta_nochange=[x for x in T3ytd if x in T3ytdlatest]
    T3delta_added=[x for x in T3ytdlatest if not x in T3ytd] 
    
    dropped = T1delta_dropped + T2delta_dropped + T3delta_dropped
    added = T1delta_added + T2delta_added + T3delta_added
    nochange = T1delta_nochange + T2delta_nochange + T3delta_nochange    
    return (dropped, added, nochange)


def dropcounter(dropped, added):
    import collections
    add_cnt = collections.Counter(added)
    new_dropped = []
    for value in dropped:
        in_add_cnt = add_cnt.get(value, 0)
        if in_add_cnt:
            added.remove(value) # preserves the order, but is a little costly
            add_cnt[value] -= 1
        else:
            new_dropped.append(value)
    dropped =  new_dropped
    drop_cnt = collections.Counter(dropped)
    return drop_cnt,dropped

    
def addcounter(dropped, added):
    import collections
    drop_cnt = collections.Counter(dropped)
    new_added = []
    for value in added:
        in_drop_cnt = drop_cnt.get(value, 0)
        if in_drop_cnt:
            dropped.remove(value) # preserves the order, but is a little costly
            drop_cnt[value] -= 1
        else:
            new_added.append(value)
    added =  new_added
    add_cnt = collections.Counter(added)   
    return add_cnt,added

    
def nochangecounter(nochange):
    import collections
    nochange_cnt = collections.Counter(nochange)
    return nochange_cnt

def OrderProfiler(mylist,db,cursor):
    # provides a list of 1s nd 0eros to describe the list in terms of paid and activity libre activities
    OrderProfile = []
    #del mylist[0] # chopping off the memberID
    mylist = mylist[1]  +  mylist[2]  + mylist[3]
    print(mylist, "this is mylist")
    for each in mylist:
        courseNumber = each
        activitydata =  activityinfo(db,cursor,courseNumber)
        #print(activitydata, "this is activity data")
        #Note activitydata[0][2] is price for 12 trim and activitydata[0][3] is for 36 trim
        if activitydata[0][2] == 0 and activitydata[0][3] == 0:
            OrderProfile.append(0) #activityLibre
        elif activitydata[0][2] >0 and activitydata[0][3] > 0:
            OrderProfile.append(1) # paid
    return OrderProfile
    
def StatusFinder (OrderProfile):
    # declares an order as being mixed (0), activity libre only(1) or paid only(2) items
    # uses OrderProfile list from OrderProfiler(mylist, db, cursoro) above
    # this status along with the ALPAID_YTD flag  in registrations table determines if DELTA ORDER should be
    # charged the activity libre registration fee, or should be reimboursed the activity libre registration fee
    print (collections.Counter(OrderProfile))
    OrderProfileCount = (collections.Counter(OrderProfile))
    if OrderProfile.count(1) >0 and OrderProfile.count(0) >0:
        print(OrderProfile, "OrderProfile")
        status = 0 #mixed
    elif OrderProfile.count(1) >0 and OrderProfile.count(0)== 0:
        status = 2 #paid_only
    elif OrderProfile.count(1) ==0 and OrderProfile.count(0)>0:
        status = 1 #free_only
    return status



def confirmpurchase():
    SwitchOn = 0
    SwitchOff = 0
    
    print("<div id='container'>")
    #print("<table width='909' border='1' cellspacing='0' cellpadding='0' summary='qsfsdsddqssd'>")
    print("<table width='909' border='1' cellpadding='1' cellspacing='1' bordercolor='#FFFFFF' bgcolor='#ECF4F4'>")
    print("<tr bgcolor='#D9F2F0'>")
    print("<th colspan='4' scope='row' align='left'> VOTRE PANIER D'ACHET :-</th>")
    print("</tr>")    
    print("<tr bgcolor='#B1D1D1'>")
    print("<th width='130' scope='row' align=center>ACTIVITE #</th>")
    print("<td width='426' align=center>DESCRIPTION </td>")
    print("<td width='130' align=center>TRIMESTRES</td>")
    print("<td width='78' align=center>PRIX (EURO)</td>")
    print("</tr>")        
    
    
    Delta_euro_total = 0
    if len(add_cnt) != 0:
        for each in add_cnt:
            print("<tr>")
            courseNumber = each
            activityinfo(db,cursor,courseNumber)
            activitydata = activityinfo(db,cursor,courseNumber)
            print("<td align=center>{0}</td>".format(activitydata[0][0]))
            print("<td align=center>{0}</td>".format(activitydata[0][1]))
            print("<td align=center>{0}</td>".format(add_cnt[each]))
            if add_cnt[each] == 3:
                print("<td align=center>{0}</td>".format(activitydata[0][3])) #using tariff36 pricing
                Delta_euro_total = Delta_euro_total + activitydata[0][3]
            else:
                print("<td align=center>{0}</td>".format(add_cnt[each]*activitydata[0][2]))
                Delta_euro_total = Delta_euro_total + add_cnt[each]*activitydata[0][2]
            print("</tr>")
            
            
    if len(drop_cnt) != 0:
        for each in drop_cnt:
            print("<tr>")
            courseNumber = each
            activityinfo(db,cursor,courseNumber)
            activitydata = activityinfo(db,cursor,courseNumber)
            print("<td align=center>{0}</td>".format(activitydata[0][0]))
            print("<td align=center>{0}</td>".format(activitydata[0][1]))
            print("<td align=center>{0}</td>".format(-drop_cnt[each]))            
            
            if drop_cnt[each] == 3:
                print("<td align=center>{0}</td>".format(-activitydata[0][3])) #using tariff36 pricing
                Delta_euro_total = Delta_euro_total - activitydata[0][3]
                
            else:
                print("<td align=center>{0}</td>".format(-drop_cnt[each]*activitydata[0][2]))
                Delta_euro_total = Delta_euro_total - drop_cnt[each]*activitydata[0][2]
                
            print("</tr>")
            
            
            
            
    if ALPAID_ytd != 1 and status == 1: #free only
        print("<tr>")
        print("<td colspan=3 scope=row align=center>Registration Activite Libre</td>")
        print("<td align=center>{0}</td>".format(activity_libre))
        Delta_euro_total = Delta_euro_total + activity_libre
        Turn_On_Alibe(db,cursor)#turns on the switch ALPAID_ytd       
        print("</tr>")            
            
            
     
    elif ALPAID_ytd != 0 and status == 0: #mixed
        print("<tr>")
        print("<td colspan=3 scope=row align=center>Reimbourse Registration Activite Libre</td>")
        print("<td align=center>{0}</td>".format(-activity_libre)) 
        Delta_euro_total = Delta_euro_total - activity_libre
        Turn_Off_Alibe(db,cursor)#turns off the switch ALPAID_ytd
        print("</tr>")       
    
           
        
    elif ALPAID_ytd != 0 and status == 2: #paid only
        print("<tr>")
        print("<td colspan=3 scope=row align=center>Reimbourse Registration Activite Libre</td>")
        print("<td align=center>{0}</td>".format(-activity_libre)) 
        Delta_euro_total = Delta_euro_total - activity_libre
        Turn_Off_Alibe(db,cursor)#turns off the switch ALPAID_ytd
        print("</tr>")
        
        
    if (currentyear - naissance) < 17 and Enrol_Status == 0:
        print("<tr>")
        print("<td colspan=3 scope=row align=center>Tarif de L'adhesion (Junior)</td>")
        Delta_euro_total = Delta_euro_total + Enroll_junior
        UpdateEnrolStatus(db,cursor)
        print("<td align=center>{0}</td>".format(Enroll_junior)) 
        print("</tr>")
        
    elif Enrol_Status == 0 :
        print("<tr>")
        print("<td colspan=3 scope=row align=center>Tarif de L'adhesion (Adult)</td>")
        Delta_euro_total = Delta_euro_total + Enroll_adult
        UpdateEnrolStatus(db,cursor)
        print("<td align=center>{0}</td>".format(Enroll_adult)) 
        print("</tr>")        
        
    
    print("<tr>") # this is the row that gives the total cost
    print("<td colspan=3 scope=row align=right>TOTAL COST......</td>")
    print("<td align=center>{0}</td>".format(Delta_euro_total))
    print("</tr>")    
    
    
    print("<tr>") # this is the row that gives the buttons
    
    print("<td scope= 'col'>")
    print("""<form method="post" action="Pay_Receipt.cgi">""")
    print("""<input type='hidden' name='mylist' id='mylist' value='{0}' />""".format(mylist))
    print("""<input type="submit" name="dfgsdf" ID="dfgfgd" value="Continuer Enregistrement" />""")    
    
    print("</form>") 
    print("</td>")
    
    print('<td><a href="orderformtwo.CGI?memberID={memberID}&token={token}">CHANGEZ VOTRE SELECTION</a></td>'.format(memberID=memberID, token=1))
    print("</td>")
    
    print("</tr>")    
    
    print("</table>") 
    print("</div>")
    return Delta_euro_total,SwitchOff,SwitchOn


def Turn_On_Alibe(db,cursor):#used above for turning on the ALPAID_ytd switch
    db,cursor=connectDB()
    cursor.execute ("""
       UPDATE registrations
       SET  ALPAID_ytd=1
       WHERE memberID={0}
    """.format(mylist[0]))
    db.commit()
    db.close

def Turn_Off_Alibe(db,cursor): #used above for turning on the ALPAID_ytd switch
    db,cursor=connectDB()
    cursor.execute ("""
       UPDATE registrations
       SET  ALPAID_ytd=0
       WHERE memberID={0}
    """.format(mylist[0]))
    db.commit()
    db.close






def SelectALPAID_ytd(db,cursor): #picks out the value of ALPAID_ytd from registration table
    cursor.execute("""select ALPAID_ytd from registrations WHERE memberID = "%s" """
    %(memberID)) 
    ALPAID_ytd=cursor.fetchall()
    return ALPAID_ytd

def Select_Enrol_Status(db,cursor): #picks out the value of Enrol_Status to determine if enrollement fee charged
    cursor.execute("""select Enrol_Status from registrations WHERE memberID = "%s" """
    %(memberID)) 
    Select_Enrol_Status =cursor.fetchall()
    return Select_Enrol_Status    
    

def SelectActivityLibre(db,cursor): #picks out the value activity libre registration charge form fees table
    cursor.execute ("""SELECT activity_libre from fees""")
    activity_libre=cursor.fetchall()
    return activity_libre

def SelectEnroll(db,cursor): #picks out the values Enroll_adult and Enroll_Junior form fees table
    cursor.execute ("""SELECT Enroll_adult, Enroll_junior from fees""")
    Enroll=cursor.fetchall()
    return Enroll








def euro_activityCnt(mylist): # This calculates the total cost of the new client order. 
    #It is complicated by fact that the cost of registering for an activity over 3 Trimesters
    # is the same as it would be if you only signed up for two trimesters - in other words
    # sign up for 2 and get the third for free. Alternatively if you sign up only quartey by
    #quarter then you do not get this price break.
    total_euro=0
    activityCount=0
    print(mylist, "this is mylisst")
    print(mylist[0],"this is mylist[0]")
    del mylist[0]
    print(mylist, "this is my list after mylist[0]")
    mylist = mylist[0] + mylist[1]  + mylist[2]
    print(mylist, "this is my list")
    count = collections.Counter(mylist)
    #print(count, "this is the counter")
    for each in count:
        del mylist[0]
        courseNumber = each
        activityCount = activityCount + count[each]
        activityinfo(db,cursor,courseNumber)
        activitydata = activityinfo(db,cursor,courseNumber)
        #print(activitydata, "this is activity data")
        if count[each] != 3:
            total_euro = total_euro + count[each]*activitydata[0][2]
        else:
            total_euro= total_euro + activitydata[0][3]
    return total_euro,activityCount,count


def activityinfo(db,cursor,courseNumber):
    cursor.execute("""select courseNumber,Activity, tariffstwelve, tariffsthirtysix from activities WHERE courseNumber = "%s" """
    %(courseNumber)) 
    activityinfo=cursor.fetchall()
    return activityinfo

def JuniorCheck(db,cursor):
    cursor.execute("""select Naissance from members2 WHERE memberID = "%s" """
    %(memberID)) 
    JuniorCheck=cursor.fetchall()
    return JuniorCheck 
    
#main program
if __name__== "__main__":
    try:
        htmlTop()
        db,cursor=connectDB()
        selection,selectionTWO,selectionTHREE,memberID = getData()
        killcommasselection(selection)
        selection = killcommasselection(selection)
        killcommasselectionTWO(selectionTWO)
        selectionTWO = killcommasselectionTWO(selectionTWO)
        killcommasselectionTHREE(selectionTHREE)
        selectionTHREE = killcommasselectionTHREE(selectionTHREE)
        memberID = ''.join(memberID)
        mylist =[memberID, selection, selectionTWO, selectionTHREE]
        
        T1ytdlatest = mylist[1]
        T2ytdlatest = mylist[2]
        T3ytdlatest = mylist[3]
        
       
        print (mylist, "this is mylist,")
        print(memberID, "this is memberID")
        
        
        UpdateInfo2(db,cursor)
        
        #print("Update SUCCESSFULL")
        
        order_ytd = SelectfromDB(db,cursor)
        #print(order_ytd, "this is the list T1ytd, T2ytd, T3ytd from database")
        T1ytd=eval(order_ytd[0][0])
        T2ytd=eval(order_ytd[0][1])
        T3ytd=eval(order_ytd[0][2])
        
        
        dropped,added,nochange = deltacalculate (T1ytd,T2ytd,T3ytd,T1ytdlatest,T2ytdlatest,T3ytdlatest)
        
        
        
        drop_cnt,dropped = dropcounter(dropped,added)
        add_cnt,added = addcounter(dropped, added)
        nochange_cnt = nochangecounter(nochange)
        
        print (drop_cnt, "this is the drop count")
        print (add_cnt, "this is the add count")
        
        #The following relate to the management of the activity libre registration. They provide the feed
        #for the confirmpurchase() form below. Notice that it was necessary to calculate the total euro
        #value of the basket (not just the delta) for use in determining if the act libre registration fee
        #should be added to or subtracted from the total DELTA value of the basket.
        
        mylist_DUPLICATE = mylist[:]  #!!!!!!!!!!!!!!!!!!!
        # NOTE ON ABOVE - duplicate of mylist needed for use with UpdateInfo1(db,cursor) function
        # THIS IS BECAUSE mylist gets destroyed by use of euro_activityCnt(mylist,total_euro=0,activityCount=0)
        # immediately. It will not therefore be available for use with UpdateInfo1(de,cursor) which is used at
        # the bottom to update registrations with T1ytd, T2ytd and T3ytd
        
        db,cursor=connectDB() 
        total_euro,activityCount,count = euro_activityCnt(mylist)
        print(total_euro, "this is total euro", activityCount, "this is total activity count")  
        
    #--------------------Now proceeding to the printout of the delta basket----------------------
        
        
        Select_Enrol_Status =Select_Enrol_Status(db,cursor)
        Enrol_Status = Select_Enrol_Status[0][0]        
    
        currentyear = datetime.datetime.now().year
        JuniorCheck = JuniorCheck(db,cursor)
        naissance = JuniorCheck[0][0]
        print(naissance, "this is naissance")
        Enroll = SelectEnroll(db,cursor)
        Enroll_adult = Enroll[0][0]
        Enroll_junior = Enroll[0][1]
        print(Enroll_adult, Enroll_junior, "adult and junior enroll")
        ALPAID_ytd = SelectALPAID_ytd(db,cursor)# ALPAID_ytd is the 1/0 value of the column which describes on or off
        ALPAID_ytd =ALPAID_ytd[0][0]# always be careful when you recover a variable from the function
        #in this case you need the [0][0] to pick out the value. Always best to print the returned value and
        #take a look at the list. This will  telll you if you have to use a [0][0] approach to get the value
        print(ALPAID_ytd, "ALPAID_ytd")
    
        activity_libre = SelectActivityLibre(db,cursor) #This getsyou the price of activity libre
        activity_libre = activity_libre[0][0]
        print(activity_libre, "activity_libre")
        
                       
        
        db,cursor=connectDB()
        
        mylist = mylist_DUPLICATE # this is the original mylist
        OrderProfile = OrderProfiler(mylist,db,cursor) #order profile describe the order in terms on 1/0 's
        # its just a list of 1's and 0's. NOTE we are talking about the FINAL order, not the DELTA order.
        
        status = StatusFinder (OrderProfile) # The above list is fed into this function, STATUS. STATUS looks
        #at the list of 1's and 0's and classifies the order into one of 3 possible types - PAID, MIXED or FREE.
        #  mixed (0), activity libre only(1) or paid only(2). This feeds into confirmpurchase() below which 
        # prints out a table of the delta sale and also indicats if the customer has to pay for activity libre
        # of gets if for free. See 
        mylist = mylist_DUPLICATE
        print(mylist,"this is my list just before confirmpurchase() runs")
        Delta_euro_total,SwitchOff,SwitchOn = confirmpurchase() # for receipt printout
    
            
        
       
        print(Delta_euro_total, "Delta_Euro Total")  
        
        
       
        
        print (ALPAID_ytd, "this is ALPAID_YTD at end ")
        print (status, "this is STATUS at end")
        
        
        
        #this updates the registration table for T1ytd,T2ytd,T3ytd - using the  values of T1ytdlatest,  T2ytdlatest
        #Remember we use the difference between the T1ytd and the TIytdlatest to calculate the DELTA value
        #of the order. IE the current incremental purchase which is the diference between these values. 
        print(mylist,"this is my list at the end of action_OrderFormTWO.cgi")
        
        #UpdateInfo1(db,cursor) 
        
        
        
        
        
        
        
        htmlTail()
    except:
        cgi.print_exception()

Open in new window

jameskaneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Walter RitzelSenior Software EngineerCommented:
Instead of the table printout, can you please post the source of that same page (table printout), after it was processed?
0
jameskaneAuthor Commented:
Thanks Walter for taking the time.

Below is the source (I hope !) you requested

   <!DOCTYPE html>
        <html lang="en">
            <head>
                <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
                <title> My Server-side template</title>
        <style type='text/css'>
         
       
    
        #container {
                position:absolute;
                left:50%;
                top:50%;
                width:909px;
                height:500px;
                margin-left: -454px;
                margin-top: -250px;
                z-index:1;
                background-color: #D9F2F0;
                text-align:center;
        }
        
       
        
        </style>

        <script type='text/javascript' src='js/jquery.js'></script> <!--//this is the jquery magic-->
        <script type='text/javascript'> //this is the jquery plugin for aligning the image vertically
            $(window).load(function(){
                /*we are using $(window).load() here because we want the coding to take
                effect when the image is loaded. */
                
                //get the width of the parent
                var parent_height = $('#the_image').parent().height();
                var image_height = $('#the_image').height();
                
                var top_margin = (parent_height - image_height)/2;
                
                //center it
                $('#the_image').css( 'margin-top' , top_margin);
            });
        </script>


            </head>
    <body>
['450738', [10, 11, 12], [10, 11, 12, 13, 15], [10, 11]] this is mylist,
450738 this is memberID
Counter() this is the drop count
Counter({10: 3, 11: 3, 12: 2, 13: 1, 15: 1}) this is the add count
['450738', [10, 11, 12], [10, 11, 12, 13, 15], [10, 11]] this is mylisst
450738 this is mylist[0]
[[10, 11, 12], [10, 11, 12, 13, 15], [10, 11]] this is my list after mylist[0]
[10, 11, 12, 10, 11, 12, 13, 15, 10, 11] this is my list
1075 this is total euro 10 this is total activity count
1000 this is naissance
70 50 adult and junior enroll
0 ALPAID_ytd
60 activity_libre
[10, 11, 12, 10, 11, 12, 13, 15, 10, 11] this is mylist
Counter({1: 10})
['450738', [10, 11, 12], [10, 11, 12, 13, 15], [10, 11]] this is my list just before confirmpurchase() runs
<div id='container'>
<table width='909' border='1' cellpadding='1' cellspacing='1' bordercolor='#FFFFFF' bgcolor='#ECF4F4'>
<tr bgcolor='#D9F2F0'>
<th colspan='4' scope='row' align='left'> VOTRE PANIER D'ACHET :-</th>
</tr>
<tr bgcolor='#B1D1D1'>
<th width='130' scope='row' align=center>ACTIVITE #</th>
<td width='426' align=center>DESCRIPTION </td>
<td width='130' align=center>TRIMESTRES</td>
<td width='78' align=center>PRIX (EURO)</td>
</tr>
<tr>
<td align=center>10</td>
<td align=center>DESSIN-PEINTURE</td>
<td align=center>3</td>
<td align=center>200</td>
</tr>
<tr>
<td align=center>11</td>
<td align=center>DESSIN - PEINTURE</td>
<td align=center>3</td>
<td align=center>310</td>
</tr>
<tr>
<td align=center>12</td>
<td align=center>DESSIN - PEINTURE</td>
<td align=center>2</td>
<td align=center>310</td>
</tr>
<tr>
<td align=center>13</td>
<td align=center>ARTS PLASTIQUES ENFANTS 6 8</td>
<td align=center>1</td>
<td align=center>100</td>
</tr>
<tr>
<td align=center>15</td>
<td align=center>ARTS PLASTIQUES ADOS 8 13</td>
<td align=center>1</td>
<td align=center>155</td>
</tr>
<tr>
<td colspan=3 scope=row align=center>Tarif de L'adhesion (Adult)</td>
<td align=center>70</td>
</tr>
<tr>
<td colspan=3 scope=row align=right>TOTAL COST......</td>
<td align=center>1145</td>
</tr>
<tr>
<td scope= 'col'>
<form method="post" action="Pay_Receipt.cgi">
<input type='hidden' name='mylist' id='mylist' value='['450738', [10, 11, 12], [10, 11, 12, 13, 15], [10, 11]]' />
<input type="submit" name="dfgsdf" ID="dfgfgd" value="Continuer Enregistrement" />
</form>
</td>
<td><a href="orderformtwo.CGI?memberID=450738&token=1">CHANGEZ VOTRE SELECTION</a></td>
</td>
</tr>
</table>
</div>
1145 Delta_Euro Total
0 this is ALPAID_YTD at end 
2 this is STATUS at end
['450738', [10, 11, 12], [10, 11, 12, 13, 15], [10, 11]] this is my list at the end of action_OrderFormTWO.cgi
 its done</body>
        </html>

Open in new window

0
Walter RitzelSenior Software EngineerCommented:
Ok, please do the following test: on the following line (375 of the page that contains the confirm purchase button):
print("""<input type='hidden' name='mylist' id='mylist' value="{0}" />""".format(mylist))

Open in new window


Then try to run. If it have worked, it means the problem you have were with the ' on the value field. Since the list have ' inside it, the HTML built was not receiving the full value correctly.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jameskaneAuthor Commented:
Fabulous !!!!

tks very much

james
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.