How to have a dynamic variable name?

I have a form that determines how many phone numbers a client has to edit by running a query against the database. The client can have anywhere from 0-3 phone numbers. I am assuming I can just wrap a CFOUTPUT QUERY tag around my input field so that it will loop if there are more than 1. What I can't figure out is how to dynamically name the input field within the CFOUTPUT tag for the UPDATE query I run after the user submits the form.
For example, if the query find that the user has 2 phone numbers in the table, how do I control their name?
<cfinput name="?" ..........>
<cfinput name="?2".........>
How can this be done dynamically within the cfoutput that is returning results of the query?

I presume you have an index number for each entry in your database. I would use that number, since you are assured it is unique.

Similar Messages

  • Dynamic Variable Names

    Okay, I just need to figure out how to make dynamic variable
    names. In this case, I have a loop, and inside the loop I need to
    create a new array for every iteration of the loop. Something like
    <cfloop from="0" to="10" index="i">
    <cfset LoopArray#i# = Some Value>
    </cfloop>
    But that doesn't work. How can you make dynamic variable
    named? I think it's probably something to do with evaluate or DE,
    but I don't know how to use them, and the livedocs make no sense to
    me. Thanks!

    On Thu, 22 May 2008 17:14:42 +0000 (UTC), kenji776 wrote:
    > Thank you both for your replied, I did manage to find a
    solution (the same one
    > posted by JR "Bob" Dobbs). Pretty much just looks
    like...
    >
    >
    > <cfloop from="1" to="3" index="i">
    > <cfset LinkResults["#i#"][1] = "Player 1's Move
    ID">
    > <cfset LinkResults["#i#"][2] = "Player 2's Move
    ID">
    > <cfset LinkResults["#i#"][3] = "Damage to player
    1">
    > <cfset LinkResults["#i#"][4] = "Damage to player
    2">
    > </cfloop>
    From your values, you don't want a two-dimensional array
    (which although
    you're actually building LinkResults as a struct, with the
    sequential
    numeric keys, it's basically an array), you want an array of
    structs, eg:
    LinkResults
    .player1.moveId
    LinkResults.player1.damage
    What is "i" actually counting through? IE: from 1-3 things...
    which are...
    what?
    Adam

  • Dynamic variable name

    Hi for all.
    I'm need create a object with "dynamic" name. For example
    Object ABCi = new ...
    where i is a indice.
    Please, help-me

    >
    Object ABC[] = new Object [size];
    for (int i=0; i<size;i++) {
    ABC[i] = ....
    }if you do something like this. How do you call one of the instances. How do you know how many there are??
    >
    Dynamic variable name? You're just making problems for
    yourselfIs there a better way? Because sometimes you have to have something like the above. Why is it a big problem?
    Thanks
    Brian

  • How do I create a variable name on the fly?

    Hi,
    If I have a String containing a value, how do I create a variable name using that value during program execution? That is if I have
    String fred = "newvar";
    How do I then create a new String with the name "newvar" (using the contents of fred)? I will never know what the content of fred is until this point. What I'd like to be able to do is something like
    String fred.subString(0) = "a new value";
    Obviously this won't work but if it did the statement would evaluate to something like
    String newvar = "a new value";
    Appreciate any help you can give,
    Dave.

    Here u go:
       private JCheckBox AddCheckBox( String strText, int nTextID )
          JCheckBox checkbox = null;
          Class checkboxDefinition;
          Class[] stringArgsClass = new Class[] {String.class};
          Constructor stringArgsConstructor;
          Object[] stringArgs = null;
          String arg = "";
          arg = "CheckBox" + nTextID;
          String label = new String(arg);
          stringArgs = new Object[] {label};
          try
            checkboxDefinition = Class.forName("javax.swing.JCheckBox");
            stringArgsConstructor = checkboxDefinition.getConstructor(stringArgsClass);
            checkbox = (JCheckBox) createObject(stringArgsConstructor, stringArgs);
            checkbox.setName(label);
            checkbox.setText(strText);
            checkbox.setSize(new java.awt.Dimension(CQuestionBase.PAGEWIDTH, 21));
            checkbox.putClientProperty("1",new Integer(nTextID));
            checkbox.setVisible(true);
          catch (ClassNotFoundException e)
            System.out.println(e);
          catch (NoSuchMethodException e)
            System.out.println(e);
          return checkbox;
       }This code was based on an example I found about two years ago. You can use the same methodolgy to create objects of any kind. Again, look at java.lang.Reflect.

  • Creating dynamic variable names

    I know there has got to a way to do this but I am not finding anything on google. I want to create a dynamic variable name like name + i so when your in a loop the names come out name1, name2 and so on till however many you want. I have tried
    int name + i = 3;
    int name[i] = 3; // which obviously won't but I had to try
    int name{i} = 3;and I am out of ideas. Thanks for all your help.

    I'd suggest using variables named j or x when posting code which uses them as array indexes.
    [i] - is for italics formatting
    [u] - is for underlined formatting
    [code] is for class Example { ... } code formatting
    etc.

  • Dynamic Variable Names in OpenScript

    Is there a way to use dynamic variable names? What I mean by this is that the variable name in the file could be:
    Name1, Name2, Name3, etc.
    I may want to loop through these by saying something like:
    For i = 0; i < iLoop; i++
    String sFieldName = "{{ViewList.Name" + Integer.toString(i) + "}}";
    JOptionPane.showMessageDialog(null, "sFieldName: " + "{{ViewList.{{sFieldName}}}}");
    I don't want it to use the literal string of {{ViewList.Name1}}, but rather, I want to use the value from the DataBank for Name1. Thanks.
    -John

    Nishanth,
    Thanks for your suggestion. Unfortunately, this is not a simple variable replacement. I want the name of the variable to be dynamic in nature. Imagine that I have 5 variables in the files named:
    Name
    FoodPref1
    FoodPref2
    FoodPref3
    FoodPref4
    I would like to loop through these and construct the variable name dynamically so it would be something similar to:
    for i=1 to 4; i++
    sFoodPrefVar = "FoodPref" + i;
    getVariables().set("FoodPref",sFoodPrefVar);
    JOptionPane.showMessageDialog(null, "Your Food Pref is: " + {{FoodPref}} + "\n");
    This is pseudo code, but it would theoretically loop through the 4 food preferences. Thanks.
    -John

  • How to give a dynamic File Name for Receiver File/FTP Adapter.

    Hi Experts,
        I have one scenario in which we are creating a flat file of IDOC which is coming from R/3 & sending it to FTP location. For this we have configured Receiver FTP adapter with File Name Scheme as "NT.out"  & in File Consturction mode i have given as "Add Time Stamp".
        therfore while creating a file it is creating as NTyyyyMMdd-HHmmss-SSS.out
    where as my requirement is only to to add Time & not the Date. (NThhmmss.out)
        How to do this ?
        for your info we are using ABAP Mapping.
        Pl help me
    Regards,
    Umesh

    Hi Umesh,
          Add one more field to your target structure for your file name and populate that field as per your requirement like NTyyyyMMdd.out. In receiver communication channel use Variable subtiution option and give the refrence of Payload and file construction mode set as create.
    And refer the below weblogs for Variable Subtiutuion File Name Scheme
    /people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i - Dynamic File Name Part 1
    /people/jayakrishnan.nair/blog/2005/06/28/dynamic-file-namexslt-mapping-with-java-enhancement-using-xi-30-sp12-part-ii - Dynamic File Name Part 2
    Hope this way would be solve u r problem.
    Cheers
    Veera
    >>>Reward points, if it is needful

  • Dynamic Variable name (for int/long) from a String variable

    Hi,
    I want to give a int/long variable name from a String.
    for ex.
    String str = lookup + "Id";
    lookup is a String variable coming from XML. Now, for instance lookup="name". So str = "nameId".
    Now I want to create a int/long variable by nameId.
    Could anybody tell me the way how to do. Please don't tell to use MAP.
    Edited by: Shah on Dec 5, 2007 3:26 PM

    Well you can't. Use a Map.
    The compiler translates variable names into slot numbers, either within an object or withing the local "stack frame" and these slot numbers are assigned names at compile time. No new slots can be created at run time. Java is not Basic.
    Reflection allows you to find existing field names and methods (not local variables), so it's possible to map, for example, XML attribute names to field names or setters in an object but the names have to be known at compile time.

  • Dynamic variable name generation

    Hi people,
    Is there any way of generating variable names dynamically in java in a loop? i.e.
    for(int i = 0; i<arrayLength; i++) {
    ArrayX.add(position, object)
    X++
    Where X is 0,1,2...etc. so i would have Array1 with something in it, Array2 with something in it, Array3 and so on.
    This is just a simple example but I've basically got an initial array of URL objects and then I want to call my getURL method on each link in my inital array and store the links associated to each initial URL in a different Array.
    Hope it makes sense, and i hope someone can help!
    Thanks in advance.

    Your example code is not clear to me (what is "position?"), and your description using URLs doesn't seem to need what you are asking for. I would be careful about using arrays - people sometimes use arrays when classes should be used.
    Anyway, I think you can get close to what you want by using a HashMap. You can use Strings as keys and the Strings would be "array01" "array02" etc.

  • AS2 syntax and dynamic variable names

    Hi all,
    Trying to learn AS2 and hoping someone can help me by
    explaining the problems with the following sample code and what
    would be needed to make it work (i.e. to create dynamic variables
    and movie clips from an array).
    Thanks for your time!

    kglad: Thanks for the super-quick and tremendously helpful
    response! Much appreciated!
    A couple of quick follow-up questions:
    kglad wrote that "createEmptyMovieClip() returns a reference
    to the created movieclip".
    How would I use/access this reference?
    Also, in the updated code below, I have two issues:
    1. rolling over a movie clip yields "this is button
    undefined" rather than "this is button a" for example; and
    2. clicking on a movie clip outputs the result of the trace
    command for all four clips (in reverse order) rather than just the
    one clicked.
    Any insights into what I need to do differently? Thanks
    again!

  • Dynamic variable names and invalid_character_err

    I'm neither an expert at structure notation nor dynamic
    variable naming conventions and would appreciate any help with the
    following. Thanks!
    This code works fine.
    <cfset idx="123">
    <cfset form.product[idx]=StructNew()>
    <cfparam name="form.product[idx].product_nm"
    default="Raspberry Jam">
    <cfform name="data_entry" method="post" format="flash"
    height="525" width="675" action="formdump.cfm">
    <cfformgroup type="tabnavigator" height="400"
    width="650">
    <cfformgroup type="page" label="Product #idx#">
    <cfinput name="static_form_name" type="text"
    label="Product" value="#form.product[idx].product_nm#" height="350"
    width="600" readonly="yes">
    </cfformgroup>
    </cfformgroup>
    </cfform>
    The following code results in the following error:
    "ORG.W3C.DOM.DOMEXCEPTION ERROR. Message: INVALID_CHARACTER_ERR: An
    invalid or illegal XML character is specified." The only change is
    in the "name" attribute of the <cfinput> tag:
    <cfset idx="123">
    <cfset form.product[idx]=StructNew()>
    <cfparam name="form.product[idx].product_nm"
    default="Raspberry Jam">
    <cfform name="data_entry" method="post" format="flash"
    height="525" width="675" action="formdump.cfm">
    <cfformgroup type="tabnavigator" height="400"
    width="650">
    <cfformgroup type="page" label="Product #idx#">
    <!--- Change value of name attribute from
    "static_form_name" to "product[idx].product_nm" --->
    <cfinput name="product[idx].product_nm" type="text"
    label="Product" value="#form.product[idx].product_nm#" height="350"
    width="600" readonly="yes">
    </cfformgroup>
    </cfformgroup>
    </cfform>
    Pam Grieger
    [email protected]

    Thanks for the info. Knowing what WON’T work is
    helpful!
    Here’s what I’m trying to do. I’m rewriting
    one of my apps, switching out conventional HTML form controls for
    <cfform> controls in Flash format. Many of the existing forms
    in my app are for updating data contained in a central database.
    When such a form is rendered to the screen, each form control is
    pre-populated with existing data. All form controls are named
    dynamically based upon the unique ID of the record being updated.
    Here’s a streamlined but typical example:
    <!--- User selected projects 14, 15, 16, and 17 for
    update. Get existing project data. --->
    <cfquery name="get_project_detail"
    datasource="#application.DataSource#">
    SELECT project_oid_nbr, project_nm
    FROM project_table
    WHERE project_oid_nbr IN (14,15,16,17)
    ORDER BY project_oid_nbr
    </cfquery>
    <!--- Initialize the project_nm form control. Form names
    are dynamic, based upon get_project_detail.project_oid_nbr. --->
    <cfloop query="get_project_detail">
    <cfparam name="form.project_nm_#project_oid_nbr#"
    default="#get_project_detail.project_nm#">
    </cfloop>
    <!--- Create HTML form control. --->
    <table>
    <cfloop query="get_project_detail">
    <tr>
    <td>
    <cfoutput>
    Project #project_oid_nbr#:
    <input type="text" name="project_nm_#project_oid_nbr#"
    value="#Evaluate("form.project_nm_#project_oid_nbr#")#">
    </cfoutput>
    </td>
    </tr>
    </cfloop>
    </table>
    This has been working just fine. However, I’m wondering
    if using the Evaluate() function is the most efficient way to go.
    Therefore I wanted to use structure notation to avoid the
    Evaluate() function, but as mentioned in my original post, this
    naming convention won’t work with <cfform> tags.
    Any suggestions as to the most efficient way to get the same
    result while still using <cfform> tags? Thanks so much!

  • JSP : create variable dynamic variable name and get his value.

    //HI forums.sun.com !
    //What I want to do is above :
    //out.println("<td style=\"width: "+col_width_+h+" \">")
    //Variable Declaration
    String col_width_1 = "100px";
    String col_width_2 = "150px";
    //etc String col_width_N = "XXXpx";
    //loop
    for (int h = 0; h < hrecset.getRowCount(); h++)
    //some code
    //create the variable name (exemple : col_width_0 ) with the "loop counter name" to get the value
    out.println("<td style=\"width: "+col_width_+h+" \">")//Do you understand what i mean?
    //some code
    //Variable Declaration
    String col_width_1 = "100px";
    String col_width_2 = "150px";
    //etc String col_width_N = "XXXpx";
    //loop
    for (int h = 0; h < hrecset.getRowCount(); h++)
    //some code
    //create the variable name with a concat with the loop counter variable name to get the value of the concatened variable
    out.println("<td style=\"width: "+col_width_+h+" \">")//Do you understand what i mean?
    //some code

    I apologize
    1) Sure i understand it but i click on the "code" button after i inserted the text above but it doesn't worked now it do.
    2) Because the table element need to have the total width in the HTML table TAG equal to the addition of every HTML td TAG to be W3 conform
    because i have a lot of cell where i want to adjust the width.
    so here my solution
    <%
    //Variable für Breite
    String col_width_unit = "px"; // px, cm,
    Integer total_table_width = 0;
    String[] col_width=new String[3];
    col_width[0] =  "350";
    col_width[1] =  "75";
    col_width[2] =  "50";
    %>
    <table style="page-break-inside:avoid;width:<%=gesamt_table_width+col_width_unit%>;">
    <%
    for (int h = 0; h < hrecset.getRowCount(); h++)
    out.println("               <td id =\"cell"+h+"\" class=\"tdall\"  style=\"width:"+col_width[h]+col_width_unit+"\" >");               
    %>
    </table>thank you very much

  • How to move a dynamic variable to a FIELD-SYMBOL

    Hello:
    i would like to ask a favor i have been trying to move a dynamic variable to a FIELD-SYMBOL but, when i compile the programm it send a error message that say 'error with assign'.
    The FS is declared like this
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE, <dyn_wa>.
    and then there is a PERFORM that send a dynamic varible and then this variable is asigned to the <dyn_table> and after of this one variable is created like this CREATE DATA wa_dynamic LIKE LINE OF <dyn_table>.
    and finalilly there is a sentences where i trying to send the wa_dynamic to the <dyn_wa>.
    here is where the error appear.
    if you have any tips for this problem i will appreciate.
    thanks a lot
    Definition of FS
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE, <dyn_wa>.
    PERFORM
    Create dynamic internal table and Assign it to Field Symbol
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fldcat
        IMPORTING
          ep_table        = it_dynamic.
      ASSIGN it_dynamic->* TO <dyn_table>.
    Create dynamic work area and assign to FS
    CREATE DATA wa_dynamic LIKE LINE OF <dyn_table>.
    ASSIGN wa_dynamic->* TO <dyn_wa>. "HERE IS THE PROBLEM

    How is wa_dynamic defined?
    data: wa_dynamic type ref to data.
    Regards,
    Rich Heilman

  • How to get work area - Variable name at runtime

    hi all,
    in this snippet.
    how can we retrieve the field name.
    this write statement merely writes the contents stored.
    how is it possible to write the field name.............?
    DO.
            ASSIGN COMPONENT sy-index
                   OF STRUCTURE <wa> TO <comp>.
            IF sy-subrc = 0.
              WRITE / <comp>.
            ELSE.
              EXIT.
            ENDIF.
          ENDDO.
    Naveen...

    In More detail....
    Find the help ID for various fields:
    TYPES: MYTYPE LIKE SBOOK-CLASS.
    DATA: F1       LIKE SBOOK-LUGGWEIGHT,
          F2       TYPE MYTYPE,
          F3       LIKE F1,
          HLP(30)  TYPE C,
          NAME(30) TYPE C VALUE 'SBOOK-ORDER_DATE'.
    FIELD-SYMBOLS: <G1>, <G2>.
    DESCRIBE FIELD F1 HELP-ID HLP. WRITE: /(5) 'F1:', HLP.
    DESCRIBE FIELD F2 HELP-ID HLP. WRITE: /(5) 'F2:', HLP.
    DESCRIBE FIELD F3 HELP-ID HLP. WRITE: /(5) 'F3:', HLP.
    ASSIGN (NAME) TO <G1>.
    DESCRIBE FIELD <G1> HELP-ID HLP. WRITE: /(5) '<G1>:', HLP.
    ASSIGN F2 TO <G2>.
    DESCRIBE FIELD <G2> HELP-ID HLP. WRITE: /(5) '<G2>:', HLP.
    Result: The following help IDs are output:
       F1:   SBOOK-LUGGWEIGHT
       F2:   SBOOK-CLASS
       F3:   SBOOK-LUGGWEIGHT
       <G1>:
       <G2>: SBOOK-CLASS

  • How to retreive the dynamic file name in the AAE configuration?

    Hi Guys,
    I have configured File to File with the integrated configuration and in the mapping i need to retreive the file name dynamically and i am unable to retreive it from the run time in AAE configuration. I am able to retreive with the normal configuration where integration engine is the run time.
    I am using the code as below.  Is it possible to retreive the file name dynamically in the AAE configuration? any help or suggestions would be appreciated.
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String ourSourceFileName = conf.get(key);
    return  ourSourceFileName;
    Thanks,
    Srini

    Hello Srinivas,
    Brief Solution:
    1. Using dynamic configuration, set the attribute value of payload dynamically to ASMA
    2. Using AF module, write the value of ASMA in a variable
    3. Using the variable substitution, set the receiver file name schema
    Plz go through the below link:
    http://wiki.sdn.sap.com/wiki/display/XI/CombiningthreedifferentaspectsofPIinoneshot
    Thanks,
    Satya Kumar

Maybe you are looking for

  • HT3782 I need to know how to get my downloads to show up again in my download window on my MacBook Pro

    I recently cleared all my downloads from my download window, and now when I download something it will not show up in the download window.  Can anyone help me or tell me what I need to do to get this to work again?  Thanks! ann227

  • Accounting Document not cleared while billing

    Hi Experts, I am not an abaper! I tried creating a sales order (sold to party is taiwan)  Had a credit hold , Released it , created delivery , Performed PGI, and finally i try to do the billing via VF01. When i do the billing account docment got gene

  • Outputing Results of XML parse

    Hi all, i hope im in the right forum, i have managed to access an Xml page and parse the various info i wanted from it and display it, i just wanted to know th easiest to way to save the outout to a word or excel or even text file so i dont lose the

  • Can we receive EDI as a String through WCF in to the orchestration receive location

    Hi, I had expose the orchestration as WCF service. Now i want to send the EDI file using WCF client to the receive location. So that my EDI file goes into the orchestration receive port and i would get the XML on the Send port. How i can achieve this

  • IPOD TOUCH AND HOME STEREO

    All, New to the board. I have an Ipod Touch, and wanted to play it through my home stereo which is a Denon, and has the Aux outputs in the front. There is a Video - aux, and 2 slots for audio. I went and bought the cable that indicated for IPOD (Touc