Trying to move a list of form variables to session variables of the same name

I am trying to move a list of form variables to session variables of the same name and I am having a lot of trouble.
I have never had to post of this forum with a language question in all the 10 years I have been using ColdFusion. I was a qa Engineer @ Allaire/Macromedia back when it was going from one to the other. I have a pretty good grasp of the language.
I have software that runs off a list. The fieldnames are variable and stored off in an array. It's survey software that runs off a "meta file". In this example; I have the number of fields in the survey set to 12 in the "metafile". I have each field declared in that file in array Session.SurveyField[1] and the above loop works fine. I include this "metafile" at the start of the process.
I cfloop around a struct and it works wherever I have needed to use it; such as here - writing to the database for example;
<CFQUERY NAME="InsertRec" DATASOURCE="Survey">
INSERT into #variables.SurveyTableName#
(EntryTime
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
,#Session.SurveyField[arrayindex]#
</cfloop>
<!--- EXAMPLE OF WHAT THE ABOVE GENERATES
,q01_name,q02_AcadTechORNA,q03_Water,q04_FirstAid,q05_CPR,q06_LifeGuard,q07_AED
,q08_ProjAdv,q09_Color,q10_SantaClaus,q11_Supervisor,q12_SupervisorOpinion --->
   VALUES
    ('#EntryTime#'
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thisname = "Session." & Session.SurveyField[arrayindex]>
,'#evaluate(variables.thisname)#'
</cfloop>
<!--- EXAMPLE OF WHAT THE ABOVE GENERATES
,'#Session.q01_name#','#Session.q02_AcadTechORNA#','#Session.q03_Water#','#Session.q04_Fi rstAid#'
,'#Session.q05_CPR#','#Session.q06_LifeGuard#','#Session.q07_AED#','#Session.q08_ProjAdv# ',
,'#Session.q09_Color#','#Session.q10_SantaClaus#','#Session.q11_Supervisor#','#Session.q1 2_SupervisorOpinion#' --->
</CFQUERY>
NOW HERE'S THE PROBLEM: I am running into trouble when trying to move the form variables to session variables of the same name. It is the only part of the software that I still need the datanames hard coded and that is a roadblock for me.
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thissessionfield = "Session." & Session.SurveyField[arrayindex]>
<cfset thisformfield = "Form." & Session.SurveyField[arrayindex]>
<cfset #thissessionfield# = #evaluate(thisformfield)#>
</cfloop>
I have tried it with or without the "evaluate"; same result. It doesn't give an error; it just ignores them (session variables look as such in the next page in the chain)
q01_name=
q02_acadtechorna=
q03_water=
q04_firstaid=
q05_cpr=
q06_lifeguard=
q07_aed=
q08_projadv=
q09_color=
q10_santaclaus=
q11_supervisor=
q12_supervisoropinion=
Note: they exist because I CFPARAM them in a loop like the above at the start of the procedure) - and this works just fine!
<cflock scope="Session" type="EXCLUSIVE" timeout="30">
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset dataname = "Session." & Session.SurveyField[arrayindex]>
<cfparam name="#variables.dataname#" default="">
</cfloop>
</cflock>
I EVEN tried exploiting the Form.Fieldnames list using CFLoop over the list and the same sort of logic within and it still gives me nothing....
Here's the FORM.FIELDNAMES value
"Q01_NAME,Q02_ACADTECHORNA,Q03_WATER,Q04_FIRSTAID,Q05_CPR,Q06_LIFEGUARD,Q07_AED,Q08_PROJAD V,Q09_COLOR,
Q10_SANTACLAUS,Q11_SUPERVISOR,Q12_SUPERVISOROPINION"
Here's the logic; SAME RESULT - The session variables don't get set.
<cfoutput>
<cfloop list="#Form.FieldNames#" index="thisfield">
<!--- <br>#thisfield# --->
<cfscript>
thisSESSIONfield = "Session." & thisfield;
thisFORMfield = "Form." & thisfield;
#thisSESSIONfield# = #thisFORMfield#;
</cfscript>
</cfloop>
</cfoutput>
The CFPARAM in a loop with variable output name works just fine; so does the post (which I included above) as does the SQL Create, Param Form Variables, Param Session Variables, etc.
THIS even works for moving BLANK to each session variable, to zero them all out at the end of the process;
<cflock scope="Session" type="EXCLUSIVE" timeout="30">
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thislocalfield = Session.SurveyField[arrayindex]>
<cfscript>
thissessionfield = "Session." & thislocalfield;
</cfscript>
<cfset #thissessionfield# = "">
</cfloop>
</cflock>
Expanding on that code, you would think this would work, but it doesn't;
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thislocalfield = Session.SurveyField[arrayindex]>
<cfscript>
thissessionfield = "Session." & thislocalfield;
thisformfield = "Form." & thislocalfield;
</cfscript>
<!--- debug --->
<!--- <cfoutput>#thissessionfield# = "#evaluate(thisformfield)#"</cfoutput><br> --->
<cfoutput>
<cfset #thissessionfield# = "#evaluate(thisformfield)#">
</cfoutput>
</cfloop>
And see that debug code in the middle? To add insult to injury... When I uncomment that it shows me this. So it certainly looks like this should work....
Session.q01_name = "Me"
Session.q02_AcadTechORNA = "N/A"
Session.q03_Water = "Yes (certificate expired)"
Session.q04_FirstAid = "Yes (certificate is current)"
Session.q05_CPR = "No"
Session.q06_LifeGuard = "Yes (certificate expired)"
Session.q07_AED = "Yes (certificate expired)"
Session.q08_ProjAdv = "Yes (certificate expired)"
Session.q09_Color = "Gray"
Session.q10_SantaClaus = "Yes"
Session.q11_Supervisor = "Da Boss"
Session.q12_SupervisorOpinion = "Not a bad thing"
There must be some simpler way to do this. This way won't work against all odds even though it seems so much like it should.
So I end up having to hardcode it; still looking for an automated way to set these #@%$*@!## session variables over the list from the form variables of the same @#@!$#%$%# name. Do I sound frustrated???
No matter what I do, if I don't HARDCODE like this;
<cfset Session.q01_name = Form.q01_name>
<cfset Session.q02_AcadTechORNA = Form.q02_AcadTechORNA>
<cfset Session.q03_Water = Form.q03_Water>
<cfset Session.q04_FirstAid = Form.q04_FirstAid>
<cfset Session.q05_CPR = Form.q05_CPR>
<cfset Session.q06_LifeGuard = Form.q06_LifeGuard>
<cfset Session.q07_AED = Form.q07_AED>
<cfset Session.q08_ProjAdv = Form.q08_ProjAdv>
<cfset Session.q09_Color = Form.q09_Color>
<cfset Session.q10_SantaClaus = Form.q10_SantaClaus>
<cfset Session.q11_Supervisor = Form.q11_Supervisor>
<cfset Session.q12_SupervisorOpinion = Form.q12_SupervisorOpinion>
I always get this from my next page because the session variables are empty;
You must answer question 1.
You must answer question 2.
You must answer question 3.
You must answer question 4.
You must answer question 5.
You must answer question 6.
You must answer question 7.
You must answer question 8.
You must answer question 9.
You must answer question 10.
I tried duplicate as well, but I can not get the above to work...
Can anyone help me do this thing that one would think is simple????

I think if you use structure array syntax you should get the results you want.
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
      <cfset session[Session.SurveyField[arrayindex]] = Form[Session.SurveyField[arrayindex]]>
</cfloop>
Or probably even easier.
<cfset session = duplicate(form)>

Similar Messages

  • I'm trying to put movies onto my hard  drive but i can't put the files with the same name onto the hard drive , finder won't let me change the name

    I'm trying to put movies onto my hard  drive but i can't put the files with the same name onto the hard drive , finder won't let me change the name. What am i doing wrong?

    Make a new folder and put them in that different folder. Then the names can be the same as others already on your drive.

  • Oracle Forms 10G(tabbed canvasses not working the same as in Forms 6i)

    Hi everyone,
    I have a form which gets called from another form through a list of value. The called form(second form) has a group of tabbed canvases which get displayed depending on the parameters passed from the first form.
    The Form is working prefectly fine in Forms 6i but when I converted the same form in to forms 10G it does not seem to work the same way. The tabbed canvasses are not getting displayed. I am manually having to press the execute query to get data displayed in the tabbed canvasses. I checked the parameters that are being passed and they are the same as that in Forms 6i.
    Please let me know where my 10G Form is going wrong. Appreciate your help, please send me an email on [email protected]
    Thanks

    duplicate
    Re: Oracle Forms 10G not working as Oracle Forms 6i

  • Two AM's with the same name but different forms causes Deployment problems

    Two Masters forms, DOC & PM are cloned except for the "where clause" in the View's query and the titles in their JSP's.
    DOC workspace has a BC project and a BC4JSP Project. The BC project comprises of the EO and VO named ComVsStaticValue. In the Edit prop-> query for the VO I have specified the "where clause" as VSSV_VS_CODE='DOCTOR'.
    In Java Webserver :-
    The JSP's are located in C:\source\Doctor\ .. and the *.xml and *.class files generated by the BC proj is in C:\source\Doctor\pol_ValueSet\..
    If I execute Doctor in JWS the records are getting filtered properly.
    PM workspace has a BC project and a BC4JSP Project. Again The BC project comprises of the EO and VO named ComVsStaticValue. In the Edit prop-> query for the VO I have specified the "where clause" as VSSV_VS_CODE='PAY_MODE'.
    In Java Webserver :-
    The JSP's are located in C:\source\PMode\ .. and the *.xml and *.class files generated by the BC proj is in C:\source\PMode\pol_ValueSet\..
    If I execute PM in JWS, the PM's JSP comes (the title is correct) but the records pertaining to DOC appears. I checked the View's xml file in C:\source\PMode\pol_ValueSet\ the "where clause" is correct. The xml & classes have the same name but their contents are different.
    I want to know whether this problem is because both have the same name for the AM and the BC4JSP's property file.
    Please clarify.

    Deploying two app modules with the same name will definitely cause problems.
    The JSPs use the information in the properties file to connect to the application module and get the data they need from the appropriate View Objects in those app modules. If you have two app modules with the same name, when a JSP tries to connect, it has no way of knowing which one of the app modules to connect to if they both have the same name.
    You could:
    1. Just use one application module that contains all the View Objects you need to access.
    or
    2. Rename one of the application modules or the package it is located in so the names are distinct. If you choose this method, you will also need to update the JSPs (specifically the 'registerApplicationFrompPopertyFile' method call), and your JSP project's appmodule property file.

  • PASSING DATA FROM FORM TO REPORT (how to on the same page?)

    Hello everybody
    yes, i know it is built in a two pages design where the first holds the form and the second the report, but I want it both on the same page so that one can see what he has on the report while adds his own row to the table. Well I could do creating a form and then editing the page and then add another region. Alright. But then i dont know how to relate them together so that the data pass from the form to the report.
    Besides, the Form for filling the data needs to pass them to two separate tables, because one table contains the particulars of the location and the other the comments about each store. Easy to do that on PHP and mysql but here I am lost.
    Second thing that is driving me nuts is that I created a table named location so as to street postcode for a store, and another one for evaluation so that customers or workers add a a row evaluating services etc.
    Well, I am trying to create that form i first talked about that would hold all the fields and I am doing it out of a SQL query that picks the definitions from both tables. My XE is completely empty from any leftovers of other applications etc. I make the equijoin alright
    select l.loc_id, l.company, l.postcode, l.street,l.town, e.eval_id, e.loc_id, e.locum_reg, e.date_booked, e.items, e.addicts, e.number_staff, e.attitude_staff, e.organisation, e.stock_filing, e.agency
    from location l, evaluation e
    where l.loc_id = e.loc_id
    and i get this annoying error all the time
    ORA-20001: Unable to create form on equijoin. ORA-20001: Error page=2 item="P2_LOC_ID" id="1324114494879878" ORA-20001: Error page=2 item="P2_LOC_ID" id="1324114494879878" has same name as existing application-level item. ORA-0000: normal, successful completion
    well, if that form is made up of both tables, it will definitively have to have something in common with them! how is the item name suppose to have another name? it is made with the wizzard so supposedly the wizzard should know it but I have tried for two days 14 hours each day.
    any indication as to how solve this would be priceless for me
    thank you
    Alvaro
    =========================================================================================================
    Edited by: user12155340 on 14-Nov-2009 03:38

    I'm just guessing, but it appears since you are selecting loc_id twice (once from each table) there are two items generated called P2_LOC_ID, and that's simply not possible (well - how would the application know which one you mean if there could be two with the same name?).
    Maybe it's worth trying the following:
    select l.loc_id as "L_LOC_ID", l.company, l.postcode, l.street,l.town, e.eval_id, e.loc_id as "E_LOC_ID", e.locum_reg, e.date_booked, e.items, e.addicts, e.number_staff, e.attitude_staff, e.organisation, e.stock_filing, e.agency
    from location l, evaluation e
    where l.loc_id = e.loc_id
    Another option is creating a view on the two tables (of course you must use 2 different column aliases for the two loc_id columns in the view too, otherwise you will receive an ORA-00957: duplicate column name) and use the view for creating reports and forms - however, automatic row processing works just on one table, so you would have to create your own processes to perform the DML...
    Edit: I just saw you already got this answered in the APEX forum.
    Holger
    Edited by: schweich on Nov 18, 2009 7:58 AM

  • Question on multiple form elements with the same name !

    Hi All,
    I have a requirement in which more than one text field with the same name exists on a HTML page. We are using JSF framework (Oracle JDeveloper IDE and OC4J ) . I tried using a String array in my backing bean to handle these text boxes. When I hit the Submit, the action (method) is not invoked. But when I try with unique names everything works fine. Am I going wrong somewhere ?
    Thanks in Advance.

    You cannot have exactly the same name on objects.
    You will have to make an array of them to be able to
    o work with them properly--it will keep the names
    unique.I understand! But JSF creates its own names which are unique. The following JSF code
            <htm:tr>
                <htm:td>
                    <h:inputText value="#{Test.description}" id="description1"/>
                </htm:td>
            </htm:tr>
            <htm:tr>
                <htm:td>
                    <h:inputText value="#{Test.description}"  id="description2"/>
                </htm:td>
        </htm:tr>generates the following HTML code with unique names.
            <tr>
                <td>
                    <input id="Test:description1" type="text" name="Test:description1" />
                </td>
            </tr>
            <tr>
                <td>
                    <input id="Test:description2" type="text" name="Test:description2" />
                </td>
        </tr>
        <tr>Though I have a String Array in the backing bean, this doesn't work (The form does not submit to the method in the Backing Bean).
    Similar situation in Struts works absolutely fine.
    Any help would be appreciated !!!

  • Two forms that update differrent tables on the same page?

    I tried to add two forms that update different tables on to one page.
    Problem is when I do that the forms gives me an error saying the field does not exist. It's like it is trying to update one table with the other tables fields.
    As an example Say I have one forms that is for people table and another one that is the Jobs table.
    When I go to update the people table, it sends the data for the jobs fields too I get an error like the field job description does not exist.
    I have two different forms for these and everything.
    I would hope it is possible to have two forms that update different tables on the same page.

    I was trying the exact same thing, but i managed to work round it by setting the steps to hide one region, so the user would enter the form see one region submit the region then direct back to the same page with the different region visible and the original hidden.
    I don't know if this would be acceptable for you...

  • Installed Oracle 8i Forms 6i & 9i Developer Suite in the same machine??

    I hav installed Oracle 8i Forms 6i & 9i Developer Suite in the same machine(on Win2k), with different Oracle homes.
    earlier it was working fine,but right now when i tried to open Form Builder(9i),it shows the error as
    Microsoft Visual C++ Runtime library
    Assertion Failed!
    Program:D:Oracle_Home\bin\ifbld90.exe
    File:ut\SRC\UTJ\SRC\UTJL.C
    Line 428
    Expression: result ==utjER_SUCCESS
    For information on how your program can cause assertion
    failure,see the VC++ documentation on asserts
    (Please try to debug the application - JIT must be enabled)
    and when i try to open Reports Builder(9i) it does not open ,it shows error as below and terminates
    rwbuilder.exe - Application Error
    The instruction at "0x6550b264" referenced memory at "0x00000000".The memory could not be "read:
    Please advise what to be done.
    Thanx in advance.

    I've got a 9i database, Jdeveloper (various versions), Oracle9i Forms and 6i Forms all installed on the same machine. Just make sure you get them in separate Oracle homes..
    Regards
    Grant Ronald
    Forms Product Management

  • 8i Forms 6i & 9i Developer Suite in the same machine?

    I hav installed Oracle 8i Forms 6i & 9i Developer Suite in the same machine, with different Oracle homes.
    earlier it was working fine,but right now when i tried to open Form Builder(9i),it shows the error as
    Microsoft Visual C++ Runtime library
    Assertion Failed!
    Program:D:Oracle_Home\bin\ifbld90.exe
    File:ut\SRC\UTJ\SRC\UTJL.C
    Line 428
    Expression: result ==utjER_SUCCESS
    For information on how your program can cause assertion
    failure,see the VC++ documentation on asserts
    (Please try to debug the application - JIT must be enabled)
    and when i try to open Reports Builder(9i) it does not open ,it shows error as below and terminates
    rwbuilder.exe - Application Error
    The instruction at "0x6550b264" referenced memory at "0x00000000".The memory could not be "read:
    Please advise what to be done.
    Thanx in advance.

    I've got a 9i database, Jdeveloper (various versions), Oracle9i Forms and 6i Forms all installed on the same machine. Just make sure you get them in separate Oracle homes..
    Regards
    Grant Ronald
    Forms Product Management

  • Forms 6i and developer 10g on the same machine

    Can i have forms 6i and developer 10g on the same machine

    Jacob,
    Were you installing any patches to the Forms 6i?? I think your problem was a mix up in the environmental variables.
    multiple versions of the same Oracle product CAN* be installed successfully on the same machine, it has been done by many.
    Do not generalize one experience, since you are working on VMware, try them on one, it's easy to revert to a snapshot ;)
    Install Forms 6i first patch it configure it and restart your machine and install DS 10g, On this machine I have Forms 6i and DS 10g installed at this same moment, and it's been working fine for that last 2 years.
    Tony

  • I just transferred "all movies" to "My Passport" hard drive.  Several images of the same clips appear.  Is each image a valid clip?  Why do I have so many?

    I just transferred "all movies" to "My Passport" hard drive.  Several images of the same clips appear.  Is each image a valid clip?  Why do I have so many?

    Okay. Trash the stuff on the External Drive.
    All Movies is not a place - it's a list. Specifically its a list of all the movies on your Mac. Never interact with anything in iPhoto via these All Movies or All Images lists.
    In iPhoto select the Movies you want to move and go File -> Export. Set the Kind: to Original and export from iPhoto to this external drive.
    Then once you're sure the export has gone correctly, erase them from iPhoto.
    Regards
    TD

  • Is it possible to have a calendar and reminder list with the same name?

    I migrated from MobileMe to iCloud on the first day. MobileMe was then set up with my MacBook and so in iCal i saw my calendar events duplicated. I didn't like this so I tried deleting the MobileMe calendars first, then realised I couldn't delete all of them, it seemed that I must have one calendar. I then removed the the account setting (which would have been the smarter thing to do). A few hours later I notice that the calendars I deleted from MobileMe have been deleted from iCloud, as well as associated task/reminder lists. Luckily for me I made a backup before moving to iCloud so I've managed to recover my calendars.
    My question is: Can I make a calendar and reminder list by the same name?
    After the migration I did have some calendars and reminder lists by the same name eg. Work, Home.

    T-Storm, I'm having the same annoying delay on my X-Fi Extreme Gamer card, it's driving me nuts trying to fix it.
    I noticed that if I un-tick the Dolbly Digital Li've in the console it goes away, along with the 5. sound, %$*&^^&%!
    Is it he same with you? Try un-ticking the DDL while playing something and see if it stops the delay or not. At least it will see if the problem is the card, the connection, the optical cable, or DDL itself.
    Dolby Digital Li've works in real-time so I fear that is causing the delay rather then a bad cable or connection. But I don't know if others are getting the same delay or not, if it is DDL then everyone should be getting it.
    But, if they are not trying to play a digital signal at the same time as a anolog one they might not notice it.

  • Hello! Pls can anyone help. I am new to Lab view, having three(3) input variable entering a tank at the same time, but they not mixed?

    Pls, i really need help. I am having three (3) input variables entering a tank at the same time,but not mixed, they mixed only inside the tank. I assumed the tank to be an indicator then used bundle/unbundle didn't solve. I tried build array but still no solution. Thanks

    Abul, I would recommend posting in that other thread to follow up on your issues from before.  Also your problem is not very clear.  You may want to expand some more on what your issue, and a post a screen shot or a VI.
    Good Luck,
    Paul
    Paul Davidson
    Sound and Vibration Software Staff Product Support Engineer
    National Instruments

  • One particular plug-in that I am trying to install reports 'an engine with the same name already exists.' However I cannot find it, even using the troubleshooting routines

    Hi,
    I am trying to install a add-on that will enable Google to behave as if I am in the USA. When I try to install the add-on I get a message which says 'An engine with the same name already exists'. However, I can find no evidence of the add-on and I have been through the various troubleshooting routines. Anybody know of a way around this?
    I have looked at the list of installed plugins and cannot see it. So whty does does FireFox think it's there?

    Hey oks10,
    It sounds like the Bing plugin might have been corrupted. I would bet that it's still installed, but not working. Try removing it from the \searchplugins\ folder in your [http://support.mozilla.com/en-us/kb/Profiles#How_to_find_your_profile profile folder].
    I'd close and restart everything after you are done, then try installing it again.

  • My new purchases will not sync into my playlist and get and will not show up on my iphone playlist of the same name, and I just tried to sync a new cd into my library and it is not showing up on my iphone.

    My new purchases will not sync into my playlist and get and will not show up on my iphone playlist of the same name, and I just tried to sync a new cd into my library and it is not showing up on my iphone.

    Hello there, Capricious13.
    There are great pointers in the following Knowledge Base article. Depending on where you see the content and where you want to get it to, this should guide you to putting it in the right place:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    http://support.apple.com/kb/ht2519
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro D.

Maybe you are looking for