Dynamic form... field names and values...

Boy-Howdy. I wish I had the opportunity to stop by this forum and hang out at a time when I am not having issue, but, alas... I appreciate the brain power of the great minds that populate this forum.
I have an issue: I think I am close on this but cannot identify where my syntax is going awry. Here is a simplified edition of my situation.
I have a form with a set of dropdown menus that filter a recordset. The group of drop downs are dynamic from a database and will vary depending on what category of products a visitor is viewing.
If I browse to FRUIT: I get three options that let me filter for:
Fruit Type
- Apples
- Bananas
- Pears
Fruit Grown By:
- Organic
- Any
Fruit From:
- Domestic
- South America
- European
However, if I browse to LUMBER I get:
Wood Type:
- Pine
- Walnut
- Oak
Wood Prep:
- Pre Cut
- RAW Timber
Wood Origin:
- North America
- South America
- Europe
I have the variable naming and database values worked out. My only issue is when I browse to friuit and select apples I want apples to remain selected as I page through results.
So, the dropdown field names are dynamic. Currently set to zgen1, zgen2, zgen3. I set a variable named sr and increment it to build the progressive 1,2,3 after the field name zgen.
<cfparam name="sr" default="1">
<cfoutput group="ft_id" query="oompa2">
<strong>#f_ftrname#:</strong><br>
<select name="zgen#variables.sr#">
<OPTION value="">select...</OPTION>
<cfoutput>
<OPTION value="#ft_id#_#fs_id#">#ft_options#</OPTION>
</cfoutput>
</select>
<br><br>
<cfset sr=#sr# + 1>
</cfoutput>
But when zgen1 has a value (in this case "Apples") I can't figure out how to dynamically test for the presence of a value for each dropdown. I have dynamically created the field names (cfset xvalue="FORM.zgen#variables.sr#") to test against. However this creates a value of FORM.zgen1, FORM.zgen2, FORM.zgen3 as it loops when I want it to be Apples, Organic, Domestic.
Example:
The code:
<OPTION value="#ft_id#_#fs_id#"<cfif xvalue IS "#ft_id#_#fs_id#"> SELECTED</cfif>>#ft_options#</OPTION>
which is translating to:
<OPTION value="15_5"<cfif FORM.zgen1 IS "15_5"> SELECTED</cfif>>Apples</OPTION>
When I want it to be:
<OPTION value="15_5"<cfif 15_5 IS "15_5"> SELECTED</cfif>>Apples</OPTION>
I hope I am making sense. I would greatly appreciate it if someone could help me noodle this. I have a feeling it is not as complicated as my mind is trying to make it. Thoughts?

Three selects related type code was not the way to go - because I need each filter to be independent. I created a custom tag that argues the state for each separately up to ten filters.

Similar Messages

  • HR - dynamic selections field name and field value in the program

    HI all,
       I am using dynamic selections for a HR report.
    I have created a view with 20 fields and added it to HR report category ___00003(All fields suppressed).
    I need to check these fields in the program. But i am not able to get the field name and value in the program for dynamic selections fields.
    Please let me know how to get the field names and values in the program for dynamic selections .
    Thanks,
    Kranthi.

    You have to read the itab <i>pnpdynse</i> in your Program to obtain the Dynamic Selection values. This itab has a deep structure.. you can set a break point in one of the events before <b>get pernr</b> & in the debug mode, you will able to display the itab <i>pnpdynse</i>.. you can then identify how to get the values into your code..
    ~Suresh

  • Flat file should have source field name and value

    Hi Friends
    I have a scenario of Idoc to Flat file , where in the target structure the field name and value should be present, generally only the value is available in a flat file.The target structure is as below:
    for e.g RECTYPE is the Field Name and A is the value.
    RECTYPE,A
    DATEH,20111101
    TIMEH,173125
    RECTYPE,B
    ORDNUM,4500054536
    ORDITM,150
    SUPDAT,20090218
    PLNQTY,000000006
    MATNR,14B300
    BATCH,5697
    PLANT,3026
    DELIVTYPE,PO
    SUPPLIER,0000023305
    SUPNAME,Deutsche BP AG
    SUPADRS,Erkelenzer Strasse 20
    SUPCITY,Monchengladbach
    SUPPOST,41179
    SUPCOUN,DE
    TRUCK_NBR,7589
    BOND_FLG,X
    STG_LOC,PLCL
    LINE_ACTION,CRE
    RECTYPE,B
    ORDNUM,4500056721
    ORDITM,10
    SUPDAT,20090218
    PLNQTY,000000013
    MATNR,116703
    BATCH,6589
    PLANT,3026
    DELIVTYPE,PO
    SUPPLIER,0000023380
    SUPNAME,DOW Belgium NV
    SUPADRS,Havenlaan 7
    SUPCITY,Tessenderlo
    SUPPOST,3980
    SUPCOUN,BE
    TRUCK_NBR,7589
    BOND_FLG,X
    STG_LOC,PLCL
    LINE_ACTION,CHG
    RECTYPE,X
    DATEH,20111101
    TIMEH,173125
    RECORDS,3

    Hi,
         NameA.addHeaderLine
    Specify whether the text file will have a header line with column names. The following values are permitted:
    ■       0 u2013 No header line
    ■       1 u2013 Header line with column names from the XML document
    ■       2 u2013 As for 1, followed by a blank line
    ■       3 u2013 Header line is stored as NameA.headerLine in the configuration and is applied
    ■       4 u2013 As for 3, followed by a blank line
    This specification is only permitted if exactly one structure is defined.
    regards,
    ganesh.

  • Please help with dynamic form field names in cfloop

    Hi,
    I need to create a form with day, date, month, year and time for 12 months
    Instead of coding them 12 times, I create day,date,month,year and time fileds in my form 1 time and then I use cfloop from="1" to="12" index="i" to loop these form fields 12 times.
    I gave each form field name such as: <input type="text" name="ScheduleDate_# i #" value=" "> this way each of those field will be named differently such as:
    ScheduleDate_1, ScheduleDate_2,ScheduleDate_3, ScheduleTime_1,ScheduleTime_2, etc
    I'm facing problem when this form is submitted, I think the error has something to do with the pound sign (##) when it comes to updating the back end
    I use MS SQL
    It doesn like this:
    <CFLOOP From="1" To="12" index="k">
    <CFIF Len(Trim(Form.MeetYear_#k#)) NEQ 0 AND Len(Trim(Form.MeetTime_#k#)) NEQ 0>
    <cfquery name="CreateSchedule" datasource="#DSN#">
    UPDATE TableSchedule 
    SET SchedDay = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.SchedDay_#k##">,SchedMonth =
    <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.SchedMonth_#k##">,SchedDate =
    <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.SchedDate_#k##">,SchedYear =
    <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.SchedYear_#k##">,SchedTime =
    <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.SchedTime_#k##">
    Where SchedId = <cfqueryparam cfsqltype="cf_sql_numeric" value="#k#">  
    </cfquery>
    </CFIF>
    </CFLOOP>
    Can anyone help please?

    You can't nest hash marks. Do this instead:
    SET SchedDay = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form["SchedDay_" & k]#">
    Dave Watts, CTO, Fig Leaf Software
    http://www.figleaf.com/
    http://training.figleaf.com/

  • Dynamically assigning field name and field value

    Hi all,
    logic:
    select field1 field2 from table into workarea.
    workarea-field1 will have value as 'MATNR' or 'BUKRS'  or  'KUNNR'  or............etc
    workarea-field1 will have values as '10000025' or  '2010'  or  '102536' or  ............etc
    Now i need to dynamically assign MATNR = 10000025
                                               or   BUKRS =2010
                                               or  KUNNR = 102536
    HOW CAN WE DO THIS.

    Hi,
    Use the ASSIGN COMPONENT statement.
    Regards,
    Ankur Parab

  • Dynamic Form field name

    I have a shopping cart that creates a dynamic field for the
    quantity of each product in the cart. I need to be able to make
    sure the user does not submit a blank value. I can not use cfinput
    as per client instructions. The field is:
    <input name="Quant_#GetCart.ShowID#" type="Text"
    value="#GetCart.Quantity#" size="1" maxlength="2"
    title="Quantity"/>
    How would you go about validating Quant_#GetCart.ShowID#?
    Thanks in advance for the help/suggestions.

    LeftCorner,
    Thanks for the compliments, and for analyzing my code. It's
    cool to see you care. I agree that the find() should have been
    findNoCase(), and the inclusion of a trim() could be a good one,
    however, the evaluating is not better. In general, Evaluate() is
    becoming less used, and is being certainly phased out where it's
    not extremely necessary. There are a few arguments as to why,
    performance being one of them, readability being another. I stand
    by my code and I recommend you check out structure notation
    (structure[key] when you would normally write structure.key except
    you don't know what "key" really is) wherever possible.

  • How to get custom field name and value in data table using csom

    i am using using this code but iam not getting FieldValues property..
     internal void ReadProjectCustomFields(string strProjectName)
                string url = "https://techwhizepm.sharepoint.com/sites/rnd/";
                using (ProjectContext projContext = new ProjectContext(url))
                    SecureString passWord = new SecureString();
                    foreach (char c in "Pass@word123".ToCharArray()) passWord.AppendChar(c);
                    projContext.Credentials = new SharePointOnlineCredentials("[email protected]", passWord);
                    projContext.Load(projContext.Projects, o => o.Where(i => i.Name == strProjectName));
                    projContext.ExecuteQuery();
                    foreach (PublishedProject _t in projContext.Projects)
                        DraftProject dftproj = _t.Draft;
                        //CustomFieldCollection custs = dftproj.CustomFields;
                        CustomFieldCollection custfs = dftproj.CustomFields;
                        projContext.Load(dftproj);
                        projContext.Load(custfs);
                        projContext.ExecuteQuery();
                        ddlcfields.Items.Clear();
                        if (!custfs.Count().Equals(0))
                            ddlcfields.DataSource = custfs.AsEnumerable().Select(o=>o.Name);
                            ddlcfields.DataBind();
                        DataTable dt = new DataTable();
                        dt.Columns.Add("Name", typeof(string));
                        dt.Columns.Add("InternalName", typeof(string));
                        dt.Columns.Add("FieldType", typeof(string));
                        //dt.Columns.Add("FinishDate", typeof(string));
                        DataRow dr = null;
                        foreach (CustomField _cust in dftproj.CustomFields)
                            dr = dt.NewRow();
                            dr["Name"] = _cust.Name;
                            string intername = _cust.InternalName;
                            dr["FieldValue"] = dftproj[intername].ToString();
                            //dr["FinishDate"] = _task.Finish;
                            dt.Rows.Add(dr);
                        GridView1.DataSource = dt;
                        GridView1.DataBind();

    I am looking through the API calls in FDM Workbench, but cannot see the table (tPOVPartitions) you mentioned listed. Is this the correct name? And do I just use the function listed in the object browser to run the query?
    Furthermore (going back to my initial thoughts of using strFile), it appears that although the variable contains the .Dat filename and path, the actual file is non-existent when "BefExportToDat" is executed:
    Error:
    Error: Export failed.
    Detail: File not found.
    This would make sense, but it does make the variable "strFile" a little pointless since one cannot make use of the file in this particular event script. Do you please have any thoughts on this?

  • Trying to dynamically output form fields returns URL values

    Hello,
    If there is a better way to go about this (which is quite likely), please let me know how to go about it.
    I'm working on some code that is supposed to dynamically set the form variables as regular variables so that we can be lazy and not have to refer to the variable with form.somevariable name.
    That part works perfectly.  Until I start testing for URL conflicts in which a URL variable has the same name.  For instance. . .
    I have a form that passes two variables; FirstName and LastName.  If I hit the page, the form shows up, I input a first and last name and click submit.  The code works perfectly.
    However, if I have URL variables with the same names, the code reports the url variable values instead of the form values.
    Some sample values;
    url.FirstName = Joe
    url.LastName = Black
    form.FirstName = Steve
    form.LastName = White
    My code that exposes the form variable will correctly find the form field names, but then when I 'evaluate' the value of the given form field, it will return the value of the URL variable of the same name rather than the form variable.
    What I am really wanting (as I described briefly up above) is to have code that automatically converts client, URL and Form variables into 'regular variables' so that you don't have to write lots of extra code grabbing them later on.  Frameworks like CFWHEELS and ColdBox do this by default, but at the company I work out, we aren't using any of them.  I need it to expose the URL variables, but give presidence to form variables if they have the same name, because they are likely to be intended to do an update or such.
    The code follows  Feel free to ignore the code for the URL and client variables if you wish as they don't directly affect how the form code works, I have tested with them commented out and I get the same result.  I provided all of it to give a more complete idea of what I have been toying with so far.  Please note that I don't normally use 'evaluate'.  There is probably a better way to go, but I don't know what it is.
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    <!--- Create a form so that we can post some form variables --->
    <form action="" method="post">
        First Name <input type="text" name="FirstName" />
        Last Name <input type="text" name="lastName" />
        <input type="submit" />
    </form>
    <!--- Set a variable to hold the list of URL variable names --->
    <cfset paramsurl = structKeyList(url)>
    <cfoutput>
    <br />
    URL variables:
    <!--- Loop through the list of url variables and then dynamically set a new variable to be equal to whatever is held by it --->
        <cfloop index="i" list="#paramsurl#">
            <cfset myDynVar = Evaluate(i)>
            <!--- Let's output the dynamically created variable as a test --->
            #i# = #myDynVar#<br />
        </cfloop>
    </cfoutput>
    <!--- If form fields exist --->
    <cfif isdefined("Form.FieldNames")>
        <cfoutput>
            <b>Field Names:</b> #Form.FieldNames#
            <p>
                <b>Field Values:</b><br>
                <cfloop INDEX="TheField" list="#Form.FieldNames#">
                    #TheField# = #Evaluate(TheField)#<br>
                    <cfset TheField = Evaluate(TheField)>
                </cfloop>
            </p>
            Lets try and output the two form fields without using the "form." notation<br>
            FirstName : #FirstName# <br />
            LastName : #LastName#
        </cfoutput>
    </cfif>
    <br />
    The client variables currently available are:<br />
    <cfoutput>
        <cfset nVarCounter = 1>
        <cfloop list="#GetClientVariablesList()#" index="whichClientVar">
            #whichClientVar# : #client[whichClientVar]#<br />
            <cfset whichClientVar = Evaluate(whichClientVar)>
        </cfloop>
    </cfoutput>

    Try this:
    <cfset structAppend( FORM, {
              'alpha' = 'bravo',
              'charlie' = 'delta',
              'echo' = 'foxtrot'
    }, true ) />
    <cfset structAppend( URL, {
              'alpha' = 'zulu',
              'lima' = 'mike',
              'echo' = 'papa'
    }, true ) />
    <!--- List the scopes in ascending order of importance. --->
    <cfdump var="#FORM#" label="FORM scope" />
    <cfdump var="#URL#" label="URL scope" />
    <cfset scopes = "url,form">
    <cfloop list="#scopes#" index="i">
              <cfloop list="#structKeyList( evaluate( i ) )#" index="j">
                        <cfset structInsert( VARIABLES, j, evaluate( i & '["' & j & '"]' ), true ) />
              </cfloop>
    </cfloop>
    <cfdump var="#VARIABLES#" abort="1" label="Combined Variables Scope" />
    What I did is insert 3 key/value pairs into the FORM and URL scope.  I then dumped the scopes to show their structure and values.  Then I defined a variable (scopes) which is a list of the least important scope to the most important.  After that, the loop I do simply goes through the SCOPES, their exisiting key/values and sets them into the VARIABLES scope.  Then, when it moves to the next scope of importance, it simply puts their value into the variables scope as well (overriding in the event it already exists), thus, the scopes defined later in the list override and replace.
    Then I just dump the VARIABLES scope (you'll notice it has the I, J and SCOPES variables in there that I used to create the loop.  If you perform this action in a function, simple make the I, J and SCOPES variables part of the LOCAL scope so they won't be in your VARIABLES scope.

  • Cfoutput query and form field names

    I have a form that have two field inputs. I would like to repeat the form fields as part of a cfoutput query. The first field of the form automatically populates the different person's name (via cfoutput query) and this form field is called "tenant". The next field of the form is called "sales". The sales field is left open for user imput. The entire form is in between the cfoutput query tags. When the cfoutput query is executed, Both form fields of the form is displayed with each tenant name listed in each of the first form fields of each row. The problem I'm running into is that even though the form elements appear to display correctly, I would like the name of each of my form elements in the cfoutput query, of each row to have a different form field name like, tenant2, sales2, tenant3, sales3 etc. is that possible?
    Here's what my code look like.
    <cfform action= "addsales.cfm" method="post">
    <cfoutput query="tenantsales"><Input name="tenant" type="text" value="#office.tenant#" size="32" />
    <select name="sales"><option>$5</option><option>$10</option><option>$12</option></br></cfoutput>
    <input name="submit" type="submit" />
    </cfform>

    I cannot imagine why you would want to show a list of pre-populated input fields. What makes sense to me is a select-box. If that is indeed what you want, then you could do something like this:
    <cfform action= "addsales.cfm" method="post">
    <cfselect name="tenant">
        <option value="">Tenant</option>
    <cfoutput query="tenantsales">
        <option value="#tenantsales.tenantID#">#tenantsales.tenantName#</option>
    </cfoutput>
    </cfselect></br>
    <cfselect name="sales">
    <option value="">Sales</option>
    <option value="5">$5</option>
    <option value="10">$10</option>
    <option value="12">$12</option>
    </cfselect></br>
    <cfinput name="submit" type="submit" value="Submit" />
    </cfform>
    Like Dan, I have assumed your database table has a column for tenant ID.

  • How to pass tag name and value dynamically in the output of PCo notification?

    Hi,
    I have a requirement to develop such a scenario where there can be multiple no of tags in PCo (Say 10) but there will be single notification to push the tag name when the value got changed and the changed value to MII. for any value change for any of the tag, the notification will be trigger. So As per my knowledge I have to pass the tag name and value dynamically in the "output" tab of the notification. But need your support to find out how to pass them dynamically.
    Thanks in advance.
    Regards,
    Suman

    Hi Suman/Jeedesh,
    As per Pco notification, it will trigger whenever any of the tag value changes in Agent instance subscription items.
    For above issue, My suggestion
    1. Create DB table name TAGLIST with 200 tags as rows in columns (Tagname, TagValue)
    2. Based on notification trigger, create a transaction and update values w.r.t TagNames in above table
    3. Next time, when notification trigger with fresh value for any of the tag, cross check with existing TagName with Value and update in DB table.
    4. And in the mean time, send those Tag details vie mail trigger or as per requirement
    Instead of creating 200 notification, above is a just alternate way suggestion to achieve dynamic tag value change notification.
    Hope it might solve your problem
    Regards,
    Praveen Reddy

  • BAPI Structure populating using field name and field value frm internal tbl

    Hi Experts,
                     Need your help, my requirement is to populate BAPI import structure using its field name and filed value  stored in a internal table.  Please advise the best approach.
    Regards
    Ram.

    Hi, in an ABAP program you can make use of FIELD-SYMBOLS and the ASSIGN statement for filling the BAPI fields based on the fieldname found in the internal table. Hopes it answer your question. Succes

  • How do i have subsequent fields label and values move down the page dynamic

    how do i have subsequent fields label and values move down the page dynamicly...
    the field in question "can grow" and can become quite big...overlaping the content of the fileds below...how can i make the fields below this large field move dyanmically so there is no overlap?

    if it is the same field and it is set to can grow you just need to make sure you put space between by inserting a section below

  • Dynamic form input name

    Hi,
    My brain is frozen or something because I couldn't think out this issue.  Basically my form input radio name and value are dynamically pulled from a database.  The name of the form is concat with a name and id is from a database.  On the form processing side, how would I get all the dynamic input radio name.  The value of the input will be attach to the name.  Hope that make sense. 
    form.cfm
    <cfquery name="get_form_name" datasource="#ds#">
         SELECT id, name
         FROM records
    </cfquery>
    <cfoutput>
    <form action="form_process.cfm">
    <cfloop query="get_form_name">
    <p>name: <input type="radio" name="test_#get_form_name.id#" value="#get_form_name.name#" /></p>
    </cfloop>
    <input type="submit" value="submit">
    </form>
    </cfoutput>
    form_process.cfm
    somehow get all the input name from the FORM to set cfparam and value.  Once I have this, i have the form values that are passing over.

    Your requirement is that you want the application to remember the name of a query variable across multiple page requests. That is a typical case where you would use the session scope.
    Following your example,
    form.cfm
    <cfquery name="get_form_name" datasource="#ds#">
         SELECT id, name
         FROM records
    </cfquery>
    <cfset session.formRecords = structNew()>
    <form action="form_process.cfm" method="post">
    <cfoutput query="get_form_name">
    <p>name: <input type="radio" name="test_#id#" value="#name#" /></p>
    <cfset session.formRecords["test_#id#"] = name>
    </cfoutput>
    <input type="submit" name="sbmt" value="submit">
    </form>
    form_process.cfm
    <!--- The names and values of the form fields are stored, respectively, as key-value pairs in the structure session.formRecords--->
    <cfdump var="#session.formRecords#">
    Remarks
    1) I simplified the code somewhat. I also added post method to the form, as I assume that is what you are aiming for. Otherwise the form fields will be submitted via the URL.
    2) It seems to me the database table holds rows having distinct values of ID . Therefore, my guess is that the functionality you should be going for is <input type="checkbox"> instead of <input type="radio">.

  • Evaluating dynamically generatedform  field names

    On form submission I need to find out if check boxes exist
    and have values. The field names are generated dynamically &
    there could be many. Here's the code I've been messing with. I am
    able to find out it the field has a value if it exists, but I can't
    figure out how to combine this with isDefined("") to test for the
    field's existence and avoid the "field i not defined in form"
    errors.
    <cfloop index="a" from="1" to="#form.numRows#">
    <cfset thisname = "form." & #a# & "_Clear">
    <!--- how do I use isDefined("") at this point to avoid
    an error on the next line when the field does not exist? --->
    <cfset thisVal= Evaluate("form.#thisname#")>
    <cfoutput> #thisname# #thisVal# </cfoutput>
    </cfloop>
    Thanks in advance for any help!

    run a loop over your field names like: <cfloop index="x"
    list="#form.fieldnames#"> then you have all of your form field
    names that are defined.

  • How to get all property names and values of an bean instance at runtime?

    How can I get all property names and values of an bean instance at runtime?
    (The class of the bean instance is dynamic and I can not know before I write the code .)

    Look at Class. It has a way to get at all public methods and attributes.
    If you need to get to private attributes you can do what the Introspector does and expect the methods to follow the Bean pattern and pull the attributes out based upon that. Privates are all hidden from direct access but through the Bean Pattern they can be figured out.

Maybe you are looking for

  • Can I activate ePrint on my HP Officejet Pro 8500 Premium printer for use with my smartphone​?

    Can I activate ePrint on my HP Officejet Pro 8500 Premium printer for use with my smartphone? Any instructions?

  • Fcp to Color workflow

    I have 20 videos that I need to color correct, and am a neophyte in color... My questions are real simple, just trying to buckle down a workflow. I have a sequence in fcp. Do I have to add in all transitions prior to sending to Color (does Color embe

  • Sun app server 8.1 vs 8.2 for jsf 1.1

    Currently we have download sun studio creator 2 which comes with sun app server 8.1 as its default server. We want to make our default server in studio creator 2 as app server 8.2, since our production environment is running on 8.2. Any help will be

  • Raise Exception   Runtime error

    Error analysis A RAISE statement in the program "SAPLTHFB" raised the exception condition "ALREADY_RUNNING". Since the exception was not intercepted by a superior program in the hierarchy, processing was terminated. Short description of exception con

  • IPhoto Application not opening on OSX Mountain Lion

    iPhoto application not opeaning  after recovery of OSX mountaion Lion 10.8.4(Fresh Installation) When iPhoto is opened it pops out with this error msg Process:         iPhoto [6858] Path:            /Applications/iPhoto.app/Contents/MacOS/iPhoto Iden