[thelist] php question - changing one form value based on select choice

M. Seyon evoltlist at delime.com
Mon Oct 17 22:02:46 CDT 2005

Message from Jeniffer C. Johnson (10/17/2005 08:04 PM)

>I think this might possible, but can't think of how to do it (and can't find
>an accurate search phrase). What I want is to have a form with a select
>list, and based on which option is selected, to send a specific hidden value
>with the other values when the form is submitted. So if, for example, Large
>is selected from the Size list, then a hidden field giving price of $10 is
>sent, but if Small is selected, then the hidden field is sent assigning
>price of $8.00.


Why not do this server side after the form has been submitted?

$size = $_POST["size_field_from_form"];

switch ($size)
case "large":
   $price = 10;
case "small":
   $price = 8;

Or, do you really need to see what the selected size is? If not just assign 
the price to the value attribute of the select options

<select name="Pricing_by_Size">
<option value="10">Large</option>
<option value="8">Small</option>


More information about the thelist mailing list