I have a form that im working on, im trying to reset a field when the no value is selected from the dropdown. My form layout is as follows: [Dropdown - name : gasoiluser - values = yes/no] [Text form field, name = gasoilmargin]
So someone comes along and selects yes from the drop down, enters a value into the text box and hits submit. If they then come back later and set the gasoiluser dropdown to no and hit submit the value in the text box stays, what I would like is when no is selected on the dropdown the form resets the value of the text field to 0.00.
I have tried doing this with php without much success, so I am not sure if there is a easier more elegant solution with javascript ?.
Thanks :-)
The code I have tried is :
<?php
$query = mysql_query("SELECT * FROM hqfjt_chronoforms_data_dashboard WHERE cf_id = '1'") or die(mysql_error());
$oilprice = mysql_fetch_object($query);
$oilpricederv = $oilprice->oilpricederv;
$dervmargin = $form->data['dervmargin'];
$dervuser = $form->data['dervuser'];
if ($dervuser=="" or $dervuser=="no")
$calculateddervprice = '0.00';
else
$calculateddervprice = $dervmargin + $oilpricederv;
?>