How to make dynamic form fields updated?

This is going to be an ugly post, just be careful! :)

I have a form that retrieves his labels and text input field names dynamically from a database. Rather than having the form hardcoded, we are able to add new columns to a table and the form automatically adds the new labels and fields via CFQUERY.

When the form is completed and submitted (post method), the database is supposed to be updated. However, because our names of input fields are populated through query, we can not write a query to update static when we add new elements of form.

So, I have a solution to this (in my head), but I'm stuck in a bit of logic and can't get it in the code. I'm looking for a way to write FORM #. # fieldname # (here is where it gets ugly). Because the form sent by the post method, I find myself with a bunch of FORM.fieldname on my action page (and fieldname is generic for what are real variables).

So here's how I am update:
I have a table (let's call it table1) that contains a column of all the column names in the data table (table2). This table is used for query purposes only, no data is updated here of the form.
I have a table1 request to call all the column names in table2.
< cquery datasource = "exdb" name = "exname" >
SELECT ColumnName
FROM table1
< / cfquery >
Then I write the update query that will update the elements they are loop using CFOUTPUT:
< CFOUTPUT QUERY = "exname" >
< cfquery datasource = "exdb" name = "exupdate" >
UPDATE table2
SET #columnName # = #FORM. < columnName > #.
WHERE itemID = #FORM.itemID #.

It's my dilemma. As you can see, the cfoutput is a loop... So we will take the first element in the loop, call him 'name1 '. So our query update said SET name1 = #FORM.name1 #, and it will update the table with what was presented in the entry for name1 field. The cfoutput to loop again, this time it's of name2. SET name2 = #FORM.name2 #. Now, the form includes a hidden itemID to specify where the table should be updated, as you can see above. So, now that you see how it works, my problem is to get #FORM. < columnName > # FORM.name1, FORM.name2, etc.
In Coldfusion, you would write #FORM.variable # to call a FORM element. However, given that the variable is not defined, and allows us to fill a request, we make SHAPE #. #variable # where #variable # must be resolved before #FORM. ___ #

You are with me on this? This is very complex in the explanation, but if you need more information, I can provide more clearly. I would like to know what you think. Really, I have the solution, but to FORM #. # columnName # to solve is another problem. I think what I need is to understand the order of operations for this statement, so #columnName # resolves first.

You'll want to use the scope structure notation when dealing with your form variables. The Form.SomeVar variable can also be written as ['SomeVar']. Using this syntax, you can do something like this:

UPDATE table2
SET #columnName # = #FORM [columnName] #.
WHERE itemID = #FORM.itemID #.

You can also look on the following to help optimize your code:
(1) learn how to use - it could speed up your code a bit.
(2) according to the DB that you use, you may be able to combine all of your UPDATE within 1 SQL commands block. This will allow to do all your actions with 1 DB connection database, instead of a bunch (works in MSSQL, Oracle or MySQL, not sure)

Tags: ColdFusion

Similar Questions

  • How to make a form field with Adobe Muse?

    Hello

    I hope you can help me guys, im trying to do a one page Web form field (this form is just to get a phone number, as the registration forms have a similar field) and the problem is with the widgets I can´t clear the field name and email... Is it possible to eliminate those?

    Thanks a lot for your help

    Hello

    I fear that it is not possible to do the same, in the field name and email are required.

  • How to make a form field validate that it is the sum of the other two fields?

    Hello

    I'm creating a form, and I'd like one of the fields to validate by making sure that this field is the sum of the other two fields of the form.  Anyone have any ideas on how to go about it?  I know that I need to run a custom validation script, but I don't know where to start - I have never made one for before validation.

    Thanks for any help!

    OK, here's a sample script that I hope will clearly demonstrate the general approach. It is intended to be the validation script custom field that the user enters the value which is supposed to be equal to the sum of the other two.

    Custom validation script

    (function () {}

    Get the value that the user entered

    sVal var = event.value;

    If it is empty, do nothing else

    If (! sVal) {}

    return;

    }

    Converts a string to a number

    nVal = + sVal;

    Get the values of the fields in the form of numbers

    var v1 = + getField("text1").value;

    var v2 = + getField("text2").value;

    Add them together, rounded to two decimals, converting to the number

    var sum = + util.printf ("%.2f", v1 + v2);

    Compare the value of the sum of the other two fields

    Change the user if they do not match

    If (nVal! == $) {}

    App.Alert ("the value entered does not equal to the sum of text1 and text2. Please correct. «, 3) ;

    If you want the value entered was rejected, include the following

    Event.RC = false;

    }

    })();

    Replace "text1" and "text2" with real field names.

  • How to make my form dynamic flow of pages properly?

    I created a dynamicfo rm that includes several questions and extensible text fields that will have several completed pages.  I don't know how to make the form properly flow from the first page.  I can reach the form if I knew how to do this.

    If you send the form to [email protected] I'll have a look when I get the chance.

    Paul

  • How to make all the fields on one page read only (for the recipient) without having to make each field read-only?

    How to make all the fields on one page read only (for the recipient) without having to make each field read-only?

    Hello Jmbtexas4,

    By default, you will need to individually click on the fields of the form and check the 'read only' and save it. From now on, it is not possible to select all together and make the changes.

    -Usman

  • How to make a text field repeat several times?

    I have created a form with the name of a client in it - and the name is repeated at the top of each page.  How to make a text field repeat several times? Thank you!

    Make sure that all fields have the same name (LastName FirstName, MiddleName,), then set the binding in the overall binding tab.

    Paul

  • How to make uneditable Date field in ADF

    Hello

    I use Jdev 11.1.1.7.1.

    In the fragment, I added the DATE of the ENTRY component. How to make uneditable date field. He should just take the input value of the grille.

    Kindly advice me.

    Thank you

    Swathi

    Your date. MinValue must be like this:

    
                
                
                  
              
    
  • How to make a form with report and a form of inclusion in the same page?

    Hey, guys:

    I was wondering if you could have any link or examples to show how to make a form with report and a form of inclusion in the same page, these two forms are related to the same table. Our customer wants that a user can add a new row to the table in a form and see all lines created by this user in a report, the report should provide link change as well. the problem is: whenever I inserted a new line or change a line or delete a line, and submitted and return to this page, all hidden elements lost their values, this report is empty, and some display only items also lost their values. Could someone give me any suggestions?

    Thank you very much!

    Sam

    So, the problem is essentially with page elements lose their session state values when re-loading of the page. How do you define values for the elements of the hidden page? You have default values defined for those? They are based on the database column? What is the "Source" parameter for these items on the page? It is set to "Always, replace any value in session state"? You have any process of 'Empty the Cache', which is reset these values to null element?

    What is your version of the Apex?

    I would recommend that you have installed for example in apex.oracle.com. This would help to better understand the issue.

    Published by: jaouad khalifi on 13 December 2012 22:11

  • May not know how to create a form of update in a cfwindow tag

    I was finally able to figure out how to make a form for adding inside a cfwindow yesterday. But I want this form to be versatile and thus allow changes. But for the life of me, I can't understand how to move a row of data to the form inside a cfwindow. Normally, I'd spend the primary key through the URL, but if I'm trying to do here, basically it reloads the page and close the cfwindow since I have the window does not display by default value.

    My page has a list of departments. My page is called departments.cfm. For each line in the list of departments, there is a link called edit. When the user clicks on this link, I want the cfwindow to open with the completed form with the data of the list of counties for the selected line. It sounds pretty simple, except how pass the department_id to the form? If my link is < a href = "departments.cfm? id = #department_id # > Edit < /a >, displays of cfwindow tag and I can see the data in it, but then closes immediately." I finally understood that he called the page again and the cfwindow closes because I did not display by default. I'm about to drop this cfwindow and just make real via javascript popup windows. And I'm normally not in favor of making the pop-up windows, but the application I'm working on that does not have enough real estate on the screen to make a hidden form, a separate window that contains the form is my best solution.

    Someone at - it suggestions?

    Thanks Peter,.

    It worked!

  • How to make a required field in OAFramework

    How to make a required field in OAFramework when running? Please explain in detail if possible.

    Thank you
    Kumar

    Get the handle to the bean by using the following Code

    Bean = webBean.findIndexedChildRecursive ("");
    If (bean! = null & )
    {
    bean.setRequired (true);
    }

  • Simple question - how to make a readonly field

    Simple question - how to make a readonly field

    Hi DougBlincoe!

    I think you're looking for this:

    1. create the element. See "creating a Page level item.

    2. navigate to the appropriate page definition:

    Go to the Home Page of the database.

    Click the icon of the Application Builder.

    Select an application.

    Select a page.

    The definition of Page appears.

    3. under items, select the name of the element.

    The attributes for the element page.

    4. to display an item under certain conditions:

    Scroll up to Conditions.

    Make a selection in the list Type of Condition.

    Enter an expression in the fields provided.

    * 5. To make an element read-only: *.

    Scroll to display playback settings.

    Make a selection in the playlist only Type of Condition.

    Enter an expression in the fields provided.

    Click on apply changes.

    Here, you will get more information about this:

    # Create the item. See ["Creating a level of Page element" | http://download.oracle.com/docs/cd/B25329_01/doc/appdev.102/b25309/bldapp.htm#BCEFHBHG].
    # Navigate to the appropriate page definition:
    # Go to the Home Page of the database.
    # Click the icon of the Application Builder.
    # Select an application.
    # Select a page. ------------------Definition of Page appears.
    # Under items, select the name of the element. ------------------Page attributes for the element.
    # To display an item under certain conditions:
    # Conditions scroll.
    # Make a selection in the list Type of Condition.
    # Enter an expression in the fields provided.
    # To make a read-only element:
    # Scroll the display reading settings.
    # Make a selection in the playlist only Type of Condition.
    # Enter an expression in the fields provided.
    # Click on apply changes.

    Here, you can read more information about this:

    http://download.Oracle.com/docs/CD/B25329_01/doc/AppDev.102/b25309/bldapp.htm#sthref805

    I hope this helps!

  • Company Logo Image dynamic form fields

    Hello world

    I designed a dynamic form of livecycle with fields for users. In this form, I want to insert an image field in the upper left corner of the page so that users can simply add their logo to business here. I have some doubts and need some clarification on a few issues I don't know how to:

    (1) I realize that I have to use the 'Field of the Image' object so that users to import the image of the logo of their computer. It's pretty simple. However, is it possible for me to add a default image in this area which says something like "Add your logo here" and I want this default image to not display on the screen only and not in print if the user has not inserted his own logo? Is there a way to do this?

    I had a quick glance and I couldn't find anything that can answer that for me. I was thinking about it and what I've done so far is, I added another 'Image' object in the same place and I added the photo "Add your logo here" in this area. I then put his presence '(screen only) Visible' and place this object located behind the object from 'field of the Image. Bascially as long as it does not, if the user adds a logo using the field of the image, this image overlaps the 'image' object that lies behind all this. What is the right way to do it? Or y at - it another simpler way to do this?

    If what I did above is the only option, then I see that there are some limitations to it. Let me explain... Lets say that the image in the 'Image' object are the size of 2 inches wide X 1 in height. Yes, if the user places an image of the logo using the "field of view" object above that, and if the size of the logo of the user is smaller than the image on the ground at the back (let's say the user logo is only 1 in. X 1 in. height width), then when the logo image overlaps the excess width of the image behind appears and it looks bad on screen. Hope this makes sense... Wondering if there is a way around this? I use 'Fit the picture proportionally' instead of 'Scale to fit Rectangle Image' for the image field object.

    (2) another thing is, once the user inserts an image using the "Image object" field, is it possible for the user to delete this image if the user subsequently changed his mind and does not want to add a logo to it? Do I need to add a button so that users to erase the images they have added to the image field object? If so, can someone help me with the jscript for this?

    Thanks to everyone who took their time to read... Looking forward for your answer...

    Hello world

    Just an update regarding my Question 1 above:

    I struck out my old idea of placing an object image behind the object of field of view etc... etc... to show a hidden default image for logo insertion. Instead, what I've done is now, I only use the Image field object and have incorporated the image of 'Insert here the Logo' by default for this field. Beside that, I added the button 'Clear Logo' that basically clears the image in the image field. So here, if users add their logo, they simply click on this object and add their logo that will replace the default image in it. Or, if the user does not want to add any logo, they need to click on the button "Erase Logo" to rid the default image. I think it's probably better than the other method than I thought before. The only thing here is, I have to make sure that users are aware that they need to press the button 'Clear the Logo' if they want to erase the default image, otherwise it will eventually print as well.

    If anyone has any suggestions or do the same thing differently, please inform me.

    Thank you...

  • How to make a text field required at run time when the user clicks on the box?

    I had a form, there are several checkboxes fields and the text associated with the check boxes. If the use clicks on the checkbox then partner

    text fields should become mandatory. I tried the change event and the click event of the boxes. There is error in the onChnage event and I got some odd results in the click event on. Sometimes, if the user clicks the check box, then for the 1st time the field is not required, then the user onclicks the box and when the user clicks the check box for the second time the field becomes necessary, but if I turns off the option highlight the field and selects the field becomes necessary even if the user onchecks I am totally confused! To add that I have also written an incorrect code always I reached the goal? How it can be possible. I write the codes below, please help me because I am working under a deadline from the client.

    onChange event:

    var = this.boundItem (xfa.event.newText) newVal;
    if(newVal == 0)
    {
    xfa.resolveNode ("form1. Subform0.Subform1.Subform9.Subform10.Table48.Row4.Purchasecost3_1'). validate.nullTest = "disabled";
    }
    on the other
    {
    xfa.resolveNode ("form1. Subform0.Subform1.Subform9.Subform10.Table48.Row4.Purchasecost3_1'). validate.nullTest = 'error ';
    }*/

    For the onClick event:

    var a = xfa.resolveNode ("form1..") RawValue Subform0.Subform1.Subform9.Subform10.Table48.row2.CostItemRecovere d_OnlyEnergyCharges");
    App.Alert (a);
    if(a == 0)
    {
    xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck__L1_1").validate.nullTest = 'error ';
    }
    if(a == 1)
    {
    xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck__L1_1").validate.nullTest = "disabled";
    }

    Please help someone!

    Hello

    You may need this resolved at this point, but here are a few tips.

    An example of a loop in a dynamic array is here: Re: how to make invisible/visible or hidden columns with checkbox?

    You are usually not necessary to resolve the nodes, especially when the script object is in the same table as the target objects.

    For example if the table was not static your script could be simplified:

    if (this.rawValue == "1")  // this object is in Row2
    {
         Row4.ComplianceCheck_L1_1.mandatory= "error";
    ...
    }
    

    However because you will be to loop through all the rows in the table repeatable instances / then you need to resolve the nodes. Take a look at the example above.

    In your script, you have to Row8 Row4. I don't know if this is repeatable or just some of them. If we take Row4 as being repetitive, then you can apply the following to all repeatable lines.

    var vRow4 = Table48._Row4.count;
    console.println("Row4: " + vRow4); // You can delete this or comment it out after testing
    
    if (this.rawValue == "1")  // this object is in Row2
    {
         for (var i=0; i
    

    I have not tested, but it should be close to work.

    Good luck

    Niall

  • How to edit PDF form fields after registration

    I am very new for PDF forms and thought I was getting better.  I'm create forms of Word documents and need to make frequent changes to the PDF form after that I have recorded because I'm still learning.  I thought I read somewhere that you should be able to change the properties of a field after saving a copy, but that did not work.  I forgot to uncheck "Ahmed multi field" and the need to set in my text boxes but I can't change.  I continue to recreate the formula over and over again on the Word doc.

    Hi Ally1286,

    Save a copy, it is required to change the form when you have distributed the form or registered as a Reader extended PDF. In this case, if you want to add scrolling functionality to a tool to "Prepare the form" field then go in (in DC) to the title of the Toolbox on the right.

    On this screen, select the file and click Start. Double-click on the field and go to the 'Options' tab check the appropriate box.

    Let me know if it works for you.

  • How to make a form to fill out continuously?

    Adobe Acrobat 10, I make a form with a text box that flows (continued) on page 2.  It's long case notes.   How to do this?

    Thanks for the help,

    Sonya

    Not possible with an Acrobat form.

Maybe you are looking for

  • Vista cannot start because of accidentally deleted system files

    Hello my laptop was working very well until some files were accidentally deleted and now Vista cannot start.There is a message saying that I need to contact the system administrator or the manufacturer of the pc. Is there anything you could recommend

  • Satellite Pro L10 - wireless network card is not detected in Win7

    Hello I have a dual boot with XP and Win7 Pro. If I install the wireless driver from the download on XP site, no problem. I tried the same procedure using the download wireless driver on the partition Win7 using a) driver XP b) driver Vista & c) the

  • Recovery of satellite A120

    My daughter has a satellite pro a120 and for some reason he decided to really play with one thing or another, I want to go back to factory for her, but I do not have the recovery disk, is anyway I can do this without the disc?Any advice would be grea

  • Languages for spell check in Outlook Express 6.0 has lost

    I am running XP and using Outlook Express 6.0 as my main email on my spell check the language offer drop only French. How can I get the other languages especially English back. Thanks for any help Edited for clarity  

  • How to disable notification 'Get Windows 10' of the taskbar?

    * Original title: 10 Windows and taskbar Anyone know how to get rid definitely an upgrade of windows 10 come in my task bar, I already had on my other computer I deleted the list "windows update", he disappears from the bar and then when I reboot but