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

Shawn K. Quinn skquinn at speakeasy.net
Tue Oct 18 16:18:59 CDT 2005

On Mon, 2005-10-17 at 20:40 -0500, Erik Mattheis wrote:
> You would do this with JavaScript, but  it would be much wiser to come 
> up with $price on the fly in your form processing template.
> To do it with JavaScript, (if you must):
> function changePrice(form) {
>    if(form.Size.options[form.menu.selectedIndex].value == 'Large') {
>      form.hiddenprice.value = 10;
>    }
>    else if(form.Size.options[form.menu.selectedIndex].value == 'Small') {
>      form.hiddenprice.value = 8;
>    }
> }

And I could edit 10 and 8 down to, say, 0.25 or some token value. Hell,
I could even order a large and change the price to 8!

Not to mention, this won't work very well on browsers that don't have
Javascript enabled.

Always keep data which must remain immutable ON THE SERVER. In
particular, NEVER trust that data such as prices will survive unmolested
after going to the client and back.

Shawn K. Quinn <skquinn at speakeasy.net>

More information about the thelist mailing list