Skip to main content
Participant
September 3, 2006
Question

Dynamic Form field name

  • September 3, 2006
  • 1 reply
  • 444 views
I have a shopping cart that creates a dynamic field for the quantity of each product in the cart. I need to be able to make sure the user does not submit a blank value. I can not use cfinput as per client instructions. The field is:

<input name="Quant_#GetCart.ShowID#" type="Text" value="#GetCart.Quantity#" size="1" maxlength="2" title="Quantity"/>

How would you go about validating Quant_#GetCart.ShowID#? Thanks in advance for the help/suggestions.
    This topic has been closed for replies.

    1 reply

    Participating Frequently
    September 10, 2006
    I guess there's a number of ways. How about this one:
    Participating Frequently
    September 10, 2006
    Nathan, I watched your CFEcplise video on Google, I liked it a lot. Your CFUG is lucky to have you, that must have took quite a while to put togther.

    However, your code has a few problems so I think this would work better:
    Participating Frequently
    September 11, 2006
    LeftCorner,
    Thanks for the compliments, and for analyzing my code. It's cool to see you care. I agree that the find() should have been findNoCase(), and the inclusion of a trim() could be a good one, however, the evaluating is not better. In general, Evaluate() is becoming less used, and is being certainly phased out where it's not extremely necessary. There are a few arguments as to why, performance being one of them, readability being another. I stand by my code and I recommend you check out structure notation (structure[key] when you would normally write structure.key except you don't know what "key" really is) wherever possible.