Skip to main content
Known Participant
February 27, 2011
Question

Problems posting a form and not receiving correct value - value not numeric

  • February 27, 2011
  • 3 replies
  • 2359 views

Hi there

I have a websote www.swanseaflowers.com.au

a piece of code in the site:


<form action="http://www.swanseaflowers.com.au/store/view-
cart/"
method="post" name="ProductDetails">

                         <p><img alt=""
src="/swanseaflowers/assets/Image/SA61-1.jpg" style="width: 120px;
height: 120px; "
/>
</p>
                         <p>Zoe</p>
                         <p>A modern arrangement of Lilies</p>
                         <p>Select the amount that you wish to spend:
<select name="totvalue"><option selected="selected"
value="55.00">
55.00</option><option
value="75.00">
75.00</option><option
value="100.00">
100.00</option><option
value="125.00">
125.00</option></select></p>
                         <p>Note: Prices displayed above include both
Delivery Costs and GST</p>
                         <p>Quantity: <input name="quantity"
onblur="if(this.value=='){this.value='1';}" onclick="this.value=';"
type="text" value="1" />
</p>
<!-- start PayPal Form Elements -->                         <cfset
amount="totvalue">
<input name="item_name" type="hidden"
value="Zoe" />
<input name="amount" type="hidden" value="125.00"
/>
<input name="item_number" type="hidden" value="1" /> <!-- end
PayPal Form Elements -->
<input name="doaction" type="hidden"
value="addToCart" />
<input name="Add to Cart" type="submit"
value="Add to Cart" />
 </cfset></form>

<input name="amount" type="hidden" value="125.00"/>

If I change the line above to:

<input name="amount" type="hidden" value="totvalue"/>  i.e. the amount selected by the user

I get an error saying value must be numeric.

Thanks in advance

    This topic has been closed for replies.

    3 replies

    Participating Frequently
    February 28, 2011

    You are getting that error because you changed the value to a string. The value of the form field named 'amount' is now 'totvalue' NOT that value of the field named 'totvalue'.

    In order to set 'amount' to the value of 'totvalue', you will need to perform some kind of Javascript function when the form is submitted (or when 'totvalue' is changed) to set 'amount' to the value of 'totvalue'.

    Known Participant
    February 28, 2011

    OK thanks for that - any chance of a suggested sokuyion and a snippet of code>

    Thanks in advance

    Participating Frequently
    March 1, 2011

    I guess the more important question is, why do you need to opass the same value twice? As was pointed out, you already have the value of 'amount', why not just do

    <cfset form.totvalue = form.amount />

    at the top of the page that is processing the form?

    Owainnorth
    Inspiring
    February 28, 2011
    <input name="amount" type="hidden" value="totvalue"/>

    Without reading through the entire thread before my morning coffee, is it not as simple as you having forgotten the hashes around the "totvalue" string?

    Known Participant
    February 28, 2011

    Thanks for your response.

    I tried your answer and included it into the code.

    When I did so I get an error.

    The AMOUNT argument passed to the Add function is not of type numeric.

    The website is ar:

    www.swanseaflowers.com.au

    Then option store from the nav menu

    Thanks once again

    Regards

    Inspiring
    February 27, 2011

    Well, "totvalue" isn't a number now is it?  Where is the code where you are populating that hidden field with the number you want?

    Better yet, if all you are doing is putting the value of the select control into a hidden field, why bother?  You already have the value from the select.

    Known Participant
    February 27, 2011

    At one stage I did have a CFSET statement in the code:

    <cfset amount = totvalue>

    Have to admit I'm a little rusty as it has been 2-3 years since I really did any CF coding due to change in position.  If anyone can shed some light on how I correct this it would be really appreciated.

    Inspiring
    February 27, 2011

    At what point do you want this to happen - before or after you submit the form?

    And, once again, unless I'm missing something, all you want to do is copy a variable.  Why not just use the one you have?