Skip to main content
Inspiring
November 24, 2010
Answered

Save All button for dynamic form

  • November 24, 2010
  • 1 reply
  • 1690 views

Hi All,


I haven't used coldfusion for a while and I am a little stuck getting my head around a problem I have occured.  I have taken a project over from one of my colleagues so the coding is not my own. See code below....

<cfif isdefined("btnSubmit")>

     <!--- DO INDIVIDUAL UPDATE CODE HERE --->

</cfif>

<cfoutput query="getList">

     <cfform name="fmUpdList99_#applicationid#" action="list99.cfm">

          Clear:       <cfinput type="Radio" name="result" checked="No" value="CLEAR">

          Match:     <cfinput type="Radio" name="result" checked="No" value="MATCH">

          N/A:         <cfinput type="Radio" name="result" checked="No" value="NA">

          <input type="submit" name="btnSubmit" value="Save" />

     </cfform>

</cfoutput>

Now this works perfectly if I want to click on a submit button per row and save each row individually.... But what the user wants is the option to have a save all button which loops through each row and does the update code for all rows (rather than individually) depending on what is selected in the radio buttons.

Sorry if I haven't described my problem to well, its just I haven't used CF for a while now and trying my best to get back into it.

All apprciate all the help you can give.

Thanks,
George

    This topic has been closed for replies.
    Correct answer Adam Cameron.

    Well...  It is a form variable that has been submitted from my form.  But it is a dynamic variable which is causing my trouble and how to syntax it.

    The variable name #form["result"&ilist99id]# should look something like this form.result12345 when concatinated.


    The variable name #form["result"&ilist99id]# should look something like this form.result12345 when concatinated.

    Right.  So which part is the struct, and which part is the key?

    Note that the key value for structKeyExists() is a STRING... so...it can be able expression that evaluates to a string.

    "result"&ilist99id

    This is a string, isn't it...?

    So...

    ... what does structKeyExists(form, "result"&ilist99id) give you?

    --

    Adam

    1 reply

    _G_1Author
    Inspiring
    November 24, 2010

    P.s Dont think I made it clear, I need the option to have a 'save all' aswell as to save individually also.

    Inspiring
    November 24, 2010

    I do that sort of thing like this:

    On the form page:

    <cfoutput query="something">

    <input name = static_part#dynamic_part#>

    on the results page.

    <cfloop list = "#form.fieldnames#" index = ThisField>

    <cfif left(ThisField, 11) is static_part>

    <cfset ThisID = RemoveChars(ThisField, 1, 11>

    <cfset ThisValue = form[ThisField]>

    then process as required.

    _G_1Author
    Inspiring
    November 24, 2010

    Thanks for your reply Dan... Although this works when I want a save all button, but wont work if I want to save each individually also.  Any other suggesions ?