Hey Guys,
Today I am developing a JavaScript quote system,
the JS is as follows
<script type="text/javascript">
<!-- Hide this code from non-JavaScript browsers
function TotalIt() {
CostPerStairs=25;
CostPerHall=50;
CostPerSingle=35;
CostPerDouble=50;
f1=document.forms[0]; // abbreviation
RI=f1.SelR.selectedIndex;
RV=RI*CostPerStairs;
HI=f1.SelH.selectedIndex;
HV=HI*CostPerHall;
SI=f1.SelS.selectedIndex;
SV=SI*CostPerSingle;
CI=f1.SelC.selectedIndex;
CV=CI*CostPerDouble;
TV=RV*1+HV*1+SV*1+CV*1;
RV=Math.round(RV*100)/100;
HV=Math.round(RV*100)/100;
SV=Math.round(SV*100)/100;
CV=Math.round(CV*100)/100;
TV=Math.round(TV*100)/100;
f1.TotR.value=RV;
f1.TotR.value=HV;
f1.TotS.value=SV;
f1.TotC.value=CV;
f1.Total.value=TV;
return true;
}
// End hiding -->
</script>
The HTML aspect lies here
Room Type
Quantity to Clean
Stairs
– 0 –
1
2
3
4
Hall
– 0 –
1
2
3
4
Single Bedroom
– 0 –
1
2
3
Master Bedroom
– 0 –
1
2
3
4
5
Total
So – I hear you say – what is the Question?
Essentially, what I would like to add is a poscode drop down box, that initiates a minimum value for the total price TV=RV*1+HV*1+SV*1+CV*1;
The idea is that when a postcode is selected, the value of TV (total) must be a minimum price or above
The HTML I have put in for this is as follows;
<tr>
<td>Select a Postcode</td>
<td align="center"><select name="SelP">
<option>- 0 -</option>
<option>LS1</option>
<option>LS2</option>
<option>LS3</option>
<option>LS4</option>
</select>
<input type="hidden" name="TotR" onFocus="this.blur();" />
<br></td>
</tr>
However I don’t know how to put this into the Java, I have tried a few ways (basically trial and error), I think i could do it with PHP by using some if and where clauses however I’ve been stumped by the JavaScript here.
Any suggestions would be greatly appreciated.
You want
Math.max(x, y). It takes two values and returns the largest of the two, thus setting a minimum value.If
SelPcontains options with specific values (which I guess is what you’re really after) like so:Then you want something like: