It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Java Forum

need help with calculator

need help with calculator

Postby barry on Thu Nov 23, 2006 4:49 pm

i am using a java script as a calculator to multiply 3 seperate numbers

problem is when i get an answer it needs to be.. how can i put it .. made up to anouther number within a range

heres what i meen

Lets say the anser to the sum is

32

it falls within a range of lets say 30 to 40

I want to the answer to then be 40 so the number is then rounded up to 40

here is what i have so far

the php bits are numbers taken from a database so ignore them

<FORM>

<SCRIPT language="javascript">

function calculator (form){

form.answer.value = form.height.value * form.width.value * form.price.value

}

</SCRIPT>

<TABLE>

<TR>

<TD>price per sqm</TD>

<TD><label>

&pound; <? echo $row['price'] ?> per square meter <input name="price" type="hidden" id="price" value="<? echo $row['price']*0.010; ?>" />

</label></TD>

</TR>

<TR>

<TD>width cm</TD>

<TD><label>

<input name="width" type="text" id="width" size="15" />

</label></TD>

</TR>

<TR>

<TD>height cm</TD><TD><INPUT NAME="height" TYPE ="text" id="height" SIZE=15></TD></TR>

<TR><TD><INPUT TYPE ="button" VALUE="Calculate" ONCLICK="calculator(this.form)"></TD></TR>

<TR><TD>Your price for your blind is:</TD><TD><INPUT NAME="answer" TYPE="text" id="answer" SIZE=4 >

</TD></TR>

</TABLE>

</FORM>

I want the anser in the box to be rounded up

Would i use an " if " statment and if so how would i do it..

lets say the answer was 12 i want it rounded up to 20

but if the answer is 21 i want it rounded up to 25

any help would be great and thanks in advance Very Happy
barry
 
Posts: 0
Joined: Thu Nov 23, 2006 4:45 pm

Postby Grouchotron on Fri Dec 22, 2006 7:41 pm

Sorry, I can't help you. This is the java programming forum, you're looking for javascript, which is one forum down.
Grouchotron
 
Posts: 9
Joined: Fri Dec 22, 2006 2:40 am


Who is online

Users browsing this forum: No registered users and 0 guests

cron