Forums

Adding JavaScript-set span value to form data

ultrasonicTim 14 Mar, 2011
I'm not sure if I've phrased the subject properly here but I've added some JavaScript to my form to dynamically update a manually added span located at the end of a form item. The span is updated with a calculated value based on the form item value entered by the user (form item specifies qty, cost is fixed). I would like to redisplay these calculated values in the confirmation page and subsequent emails but when I try to reference the span in the confirmation/email html code with the required {name} reference, I get just {name} in the form and not the value. I looked in the AutoGenerated code tab at the Form Field names list and CF does not seem to pick up the named span I added. Is it possible to do this or is this just a terrible idea and I should do this another way?

Thanks in advance,

Tim
GreyHead 14 Mar, 2011
Hi Tim,

Only data from inputs is returned, not anything from the other HTML on the page.

You have a couple of choices: [list]
  • I prefer to use a span (or div) for the display *and* add the value to a hidden input, or
  • You can use a normal text input with the readonly='readonly' attribute set, this will both display and return a value.
  • [/list]

    Bob

    PD Don't use disabled='disabled' as this stops the value being returned.
    ultrasonicTim 14 Mar, 2011
    Perfect! Thanks again and I'll give that a try.

    Tim
    This topic is locked and no more replies can be posted.