• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Accesing Post Data in Forms using variables

Guest
Jun 05, 2009 Jun 05, 2009

Copy link to clipboard

Copied

I have a problem when I tried to access post data from a form using a variable...

Thhe form


<cfquery name="ConsultaPrecios" datasource="#Application.DB#">
    SELECT * FROM
    VwConsultaPrecios
    ORDER BY NOMBRE_PRE
</cfquery>

<cfform preservedata="yes" name="formaVentaGastos"    action="" onsubmit="verificaCampos()" enctype="multipart/form-data">

    <cfloop query="consultaPrecios">
            <cfoutput>
              <tr align="center" class="forma">
              <td class="forma" align="right">#consultaPrecios.NOMBRE_PRE# - #NumberFormat(consultaPrecios.PRECIO_PRE, "$___.__")# </td></cfoutput>
                 <td class="forma"><cfinput validate="integer" value="0" onChange="if(this.value==''){this.value=0;}validateInt(this, #consultaPrecios.PRECIO_PRE#,'#consultaPrecios.Nombre_Pre#');" maxlength="3" message="El campo de cantidad debe ser entero!!!" type="text" size="8" name="#consultaPrecios.Nombre_Pre#_venta"></td>
                 <td class="forma"><cfinput style="background-color:##999999;" validate="integer" readonly="yes" value="0" type="text" size="8" name="#consultaPrecios.Nombre_Pre#"></td>             
              </tr>
        </cfloop>

</cfform>

Processing the form

<cfloop list="#Form.FieldNames#" index="i">

        <cfif findNocase('Venta',#i#) AND NOT findNoCase('TOTAL', #i#) AND NOT findNoCase('FECHA', #i#) AND NOT findNoCase('RUTA', #i#)>
             <cfset a = 'form.Interno'>
             <cfoutput>#Ii#</cfoutput>

            <br>
        </cfif>

Views

526

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Jun 05, 2009 Jun 05, 2009

I do not beleive that I understand what you are trying to do or what probelm you are really having.

Looking at your logic, I would expect your list loop variable "i" to contain the value of "fieldnames" for one of the loop's iterations.  That logic will loop over each of the values in the list "form.fieldnames" and output one each itteration.

If you want to access the value from the form structure for each itteration, array notation is the common approach.

<cfloop list="#form.fieldnames#" index="i"

...

Votes

Translate

Translate
Guest
Jun 05, 2009 Jun 05, 2009

Copy link to clipboard

Copied

the problem is that instead of bringing variable in form value, brings the string for "i" in the collection... I want to get the value posted in the form, If I use the sintax #FORM.FIELDNAME# then it'll bring the value but using #i# will show me the String "FIELDNAME"..

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 05, 2009 Jun 05, 2009

Copy link to clipboard

Copied

I do not beleive that I understand what you are trying to do or what probelm you are really having.

Looking at your logic, I would expect your list loop variable "i" to contain the value of "fieldnames" for one of the loop's iterations.  That logic will loop over each of the values in the list "form.fieldnames" and output one each itteration.

If you want to access the value from the form structure for each itteration, array notation is the common approach.

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

  <cfoutput>#i#: #form#<br/></cfoutput>

</cfloop>

You can do the same thing with a collection loop.

<cfloop collection="#form#" item="field">

  <cfoutput>#field#: #form[field]#<br/></cfoutput>

</cfloop>

HTH

Ian

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 05, 2009 Jun 05, 2009

Copy link to clipboard

Copied

LATEST

Thank you, that was what I was looking for!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation