form field names

Discussion in 'Programming' started by a.ashabi, Mar 2, 2009.

  1. #1
    Hi.I have a form with these fields:

    <CFINPUT type="text" name="qty#x#" value="#session.myShoppingCart[x].quantity#" size="1>

    <input type="checkbox" name="emailReminder#x#" value="session.myShoppingCart[x].emailReminder"

    when I want to set the values,the qty is ok but I got an error on emailReminder which is :
    The value SESSION.MYSHOPPINGCART[X].EMAILREMINDER cannot be converted to a number.
    Here is the code for it:
    <CFLOOP list="#form.fieldNames#" index="x">
    <CFIF findNoCase("qty", x)>
    <CFSET itemNumber = ReplaceNoCase(x,"qty", "") - deleteCount>
    <CFSET itemQuantity = Evaluate(x)>
    </CFIF>
    <CFSET session.myShoppingCart[itemNumber].quantity = itemQuantity>

    <CFIF findNoCase("emailReminder", x)>
    <CFSET session.myShoppingCart[x].emailReminder = ReplaceNoCase(x,"form.emailReminder", "")>
    </CFIF>
    </CFLOOP>


    what is my mistake?please help me I’m really stucked.thanks in advanced.
     
    a.ashabi, Mar 2, 2009 IP
  2. phydiux

    phydiux Peon

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Your code:

    <input type="checkbox" name="emailReminder#x#" value="session.myShoppingCart[x].emailReminder"

    Should probably be:

    <input type="checkbox" name="emailReminder#x#" value="#session.myShoppingCart[x].emailReminder#"

    Your current code is literally trying to insert the value "session.myShoppingCart[x].emailReminder" (not a variable, the actual text itself) into a column in your database.
     
    phydiux, Mar 3, 2009 IP