Passing Arrays via URLs

Posted on 2005-04-14
Last Modified: 2010-04-25
I am creating a calculator program that allows a user to enter multiple entries and does extensive calculations after each entry and upon final entry. Upon final entry, I would like to not only display the results, but also all Input entries that the user typed.  I am currently using a form to enter data and a second program to do running/final calculations.  I can't seem to get an array to hold each entry and pass back and forth between programs for the final output.   The final calculations are correct, I just can't display all of the user entries.   can someone please give me a suggestion?  Thanks, Rhonda  
Question by:USNRetired
    LVL 16

    Accepted Solution


    For the storage of all the entries, I suggest the following method

    Using a string to store it.

    Say for an example

    When the user have the following entries

    1 + 2 =
    * 3 =
    / 4 =

    somthing like this
    then you can store it in a single variable like

    stored_entry = "1+2=|*3=|/4"
    here I use the "|" as a delimiter

    If you are using a HTML form to pass the thing
    You can declare the variable by

    <input name="stored_entry" type="hidden">

    Hope you got my idea

    Author Comment

    Thanks Vicker,
      Let me give a sample code and see if you might have another idea.
    Input screen:

    <cfform name="CalcForm" onsubmit="return isValidForm(CalcForm)" action="PAB_calc.cfm" method="get">
    <cfoutput>tot-income = #url.tot_income#</cfoutput>
      <table borderColor="#808000" borderColorDark="#808080" cellPadding="10" width="100%"
      borderColorLight="#c0c0c0" border="3">
          <Input Type="Hidden" Name="payperiods" value="#url.payperiods#" >
          <Input Type="Hidden" Name="tot_percent" value="#url.tot_percent#" >
          <Input Type="Hidden" Name="tot_dollar" value="#url.tot_dollar#">
          <Input Type="Hidden" Name="systype" value="#systype#">
                <Input Type="Hidden" Name="tot_income" value="#url.tot_income#" >
    <Input Type="Hidden" Name="tot_agency_match" value="#url.tot_agency_match#" >
          <p><b><font face="Arial"
          color="#000080" size="4">Compute Makeup Contributions to 401K systems</font></b></td>
        <tr align="center">
          <td vAlign="top" align="left" width="100%" color="#000080"><p><font face="Arial" color="#000080">
                <font face="Arial" color="#000080">Enter your basic Pay $:
              <input size="10" maxlength="7" name="income" value="<cfoutput>#url.income#</cfoutput>" ><!---onChange="return isDollarAmt(this)" > --->
    </font></td></tr><tr> <td vAlign="top" align="left" width="100%" color="#000080"><p>
            <font face="Arial" color="#000080">Enter percentage of basic pay that you wish to compute:
                <input maxLength="2" size="2" name="cont_percent" value="0" onChange="return isValidContPercent(CalcForm)">
              for each pay period.</font></p>
            <p align="left"> <font color="#000080" face="Arial"><strong><center>or &nbsp;<br></center></strong></font></p>
            <p><font face="Arial" color="#000080">Enter the dollar amount  $
           <input size="10" maxlength="7" name="payperiod_amt" value="0"> for each pay period.</font></p><p></p>  </td>
        </tr><tr> <td vAlign="top" align="left" width="100%" color="#000080"><p>
          <p><font face="Arial" color="#000080">Enter the number of pay periods:
              <input maxLength="2" size="2" name="period" value="0" onChange="return isNumberGE0(this)">
          <p><font face="Arial" color="#000080">Enter amount of contributions already made to other 401K systems $
           <input size="10" maxlength="7" name="other_amt" value="0"> </font></p>
          <p><font color="#000080" face="Arial">Enter all Matching contributions made to the other 401K Accounts $
              <input size="10" maxlength="7" name="umatch_amt" value="0"> </font></p>
       <tr align="center">
          <td vAlign="top" align="left" width="100%" color="#000080"><p><font face="Arial" color="#000080">If you have more than one amount for mulitiple pay periods, Click the &quot;Enter more Pay Period Information&quot; button. When you have entered all pay periods that you want to compute, Click on the &quot;Calculate&quot; button.
                  <INPUT TYPE="submit" name="add" VALUE="Enter more Pay Period Information" >
            <input type="submit" name="calculate"  value="Calculate">
            <INPUT TYPE="reset" VALUE="Reset"></TD>


    ----------------Second program that does the calculations and returns to the form for more input------------------------
    -------------I've only included the section that calculates the multiple entries and keeps running totals------------------
    ------------When the user is finished entering all data, there are final total calculations done and displayed-------------
    -------- I need an array (or some simple way) to pass ALL input values to the final display page.  They could enter-------
    -------from 1 to as many entries as they need to.  This would probably be a max of 10 screen entries, but  ------------------
    --------mutiple fields.  So, I need to carry a table of maybe 6 fields, 10 different values, plus all totals ----------------------
    -------This is why I was looking to pass an array.  Thanks-------------------------------------------------------------------------
    <TITLE>401K Calculator, Projecting Account Balance, Results</TITLE>
    <cfparam name="form.systype" default="">
    <cfparam name="form.cont_percent" default=0>
    <cfparam name="form.income" default=0>
    <cfparam name="form.payperiod_amt" default=0>
    <cfparam name="form.other_amt" default=0>
    <cfparam name="form.period" default=0>
    <cfparam name="form.tot_income" default=0>


    form.systype = #form.systype#
    form.cont_percent = #form.cont_percent#
    form.income = #form.income#
    form.payperiod_amt = #form.payperiod_amt#
    form.period = #form.period#
    form.uniform_amt = #form.other_amt#
    form.tot_dollar = #tot_dollar#
    form.tot_percent = #form.tot_percent#
    form.tot_income = #form.tot_income#


    <cfset tot_income = #form.tot_income# + #form.income#>

         <cfset tot_dollar = #form.tot_dollar# + (#form.payperiod_amt# * #form.period#)>
           <cfset percent = form.cont_percent / 100>
         <cfset tot_percent = form.tot_percent + ((form.income * percent) * form.period)>
           <cfset tot_uniform_amt = form.uniform_amt>
           <cfset tot_income = form.tot_income + (form.income * form.period)>
                 <cfset percent4 = 4 / 100>
          <cfset percent5 = 5 / 100>
          <cfset percent3 = 3 / 100>
          <cfset percent2 = 2 / 100>
          <cfset agency_pct1 = ((percent - percent3) / 2) + percent3>
    <!---step 5d   --->
          <cfif form.payperiod_amt gt 0>
                <cfset percent = form.payperiod_amt / 10000>
                dollar_percent = #percent#
          <!---step 5a, b, c   --->
          <cfif other_amt eq 0>
                <cfif percent eq percent5 or percent gt percent5>
                      <cfset agency_match = (form.income * percent4) * form.period>
                <cfelseif percent eq percent3 or percent lt percent3>
                      <cfset agency_match = (form.income * percent) * form.period>
                    <cfset agency_pct1 = ((percent - percent3) / 2) + percent3>
                      <cfset agency_match = (agency_pct1 * form.income) * form.period>
                <cfset tot_agency_match = form.tot_agency_match + agency_match>
                <cfset percent = ((uniform_amt / tot_income) * 100) / 100>
                <cfif percent eq percent5 or percent gt percent5>
                      <cfset agency_match = (form.income * percent4) * form.period>
                <cfelseif percent eq percent3 or percent lt percent3>
                      <cfset agency_match = (form.income * percent) * form.period>
                    <cfset agency_pct1 = ((percent - percent3) / 2) + percent3>
                      <cfset agency_match = (agency_pct1 * form.income) * form.period>
                <cfset tot_agency_match = form.tot_agency_match + agency_match>

    <!---return to form program to add multiple entries   --->
    <cfif isdefined("form.add")>
         <SCRIPT LANGUAGE='JavaScript'>
            location = ("pab_intro.cfm?tot_agency_match=#tot_agency_match#&tot_income=#tot_income#&systype=#form.systype#&income=#form.income#&tot_dollar=#tot_dollar#&tot_percent=#tot_percent#&payperiods=#payperiods#") ;

    LVL 37

    Assisted Solution

    You can also load all the inputs into a session
    CF sessions:

    ...think of your user's calculations as a "shopping cart"...each time they run the calc, an item gets added to the cart.
    Using session, you can manipulate it a bit easier than using a hidden field with one long string....

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
    This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now