Calc() Issue Not Going Over 2??
Sep 5, 2005
I have a javascript calculator that when you update a users level you click calculate and it updates there skill needed to reach the next level my problem is it only calculates as high as the number 2:
echo "<script langauage="javascript">
function calc() {
a = document.battle.newlevel.value;
b = 150;
c = document.battle.newskillneed.value;
answer = eval(a*a*b);
if(c>answer) {
document.battle.newskillneed.value = answer;
}
max.innerHTML = answer;
}
</script>";
Example: Level 2*(150 * Level 2) = 600 works fine but
Level 3*(150 * Level 3) = nothing why won't it work any higher its like there is a cap on how high it will go...
Also if I enter level 1 it comes up with 150 but if i put in level2 and press calculate it won't do anything but if i start out at level2 it works and then i move down to level 1 it works why won't it work moving up in numbers??
View 1 Replies
Jan 3, 2010
First time user of Javascript and built an online calculator, trouble is I dont know where or how to code it so the answer ends with only 2 decimals
I have embedded code, Personally I think it's a miracle the darn thing works.:thumbsup: Link to page it's on [URL]...I have searched and read but after hours of trying stuff gave up.
<!--
function treevalue() {
document.volume.result.value=(((3.14159*((document.volume.radius.value)*(document.volume.radius.valu e)))*(document.volume.height.value))/3)*(document.volume.base.value)*(document.volume.e.value)*(document.volume.fv.value)*(document.volum e.l.value);
[Code]...
View 9 Replies
View Related
Apr 21, 2010
I am trying to use select options to get birthdate and calculate the age. I got the birthday with "birthDay = document.form1.selDate;" However i'm lost on the birthMonth and birthYear. I've looked at lots of examples. The birthMonth probably needs to be converted to integer, or use 1 thru 12 rather than Jan thru Dec. But birthYear i'd think would come back as a valid number. Is anyone familiar with this?
[Code]...
View 3 Replies
View Related
Nov 16, 2010
Don Gosselin's JavaScript Fourth Edition is a tiresome read and I have been unable to put together the necessary tools that Don teaches to find the answers that I want to make the following function work.
function calculate()
var shipping = 0;
var total = 0; {
if (document.forms[0].hand_tool.value != document.forms[0].hand_tool.value == true)
(document.forms[0]item1.value == 20); {
[Code]...
View 3 Replies
View Related
Apr 14, 2005
I have an alteration to do on a multi-page form which was previous in use for single item selection and calculations only.
Now the form has to be altered to process multiple items. My difficulties lie in tackling the javascript calulations for a form that populates dynamically with as many items as the user has previously selects.
Item recordID's are POSTed to this form as an array. The array determines which item records are pulled from the database via sql. The form has, for each record, a textfield for item quantity and subtotal, and a hidden input that holds the item cost price.
Previously, this was calculated by targeting hard coded form field names, however the dynamic nature of this form requires dynamic targeting or a different field naming strategy all together so that the javascript function can iterate through the form fields and calculate subtotals and total on the fly.
Here's the code so far;
The previous calculation function for the single item form:-
function calcForm(){
qty = parseFloat(document.confirmTicketPurchase.ticketQty.value)
if (isNaN(qty)){
alert("You must enter a valid number into the Enter Quantity field")
return false
}
if(qty <=0 || qty % 1 != 0 ){
alert("You must enter a quantity of tickets between 1 and 999 only")
return false
}
costPer = parseFloat(document.confirmTicketPurchase.perticketCost.value)
total = costPer*qty
document.confirmTicketPurchase.ticketCost.value = total
return true
}
I have to edit this javascript function to work with the following form and edit the form field names to suit the function.
The new form :-
<form action="#" name="confirmTicketPurchase" id="confirmTicketPurchase" method="POST">
<table border="0" cellpadding="2" cellspacing="1" class="dataTable">
<tr class="trTopRow">
<td colspan="2">You Have Selected The Following Ticket/s</td>
</tr>
<?php do { ?>
<tr class="trOdd">
<td colspan="2"><strong><?php echo $row_rsTickPurchase['ticketName']; ?></strong></td>
</tr>
<tr class="trEven">
<td width="36%">Enter Quantity:</td>
<td width="64%" class="algn_R"><input name="ticketQty" type="text" id="ticketQty" value="1" size="4" maxlength="4" onkeyup="calcForm()" /></td>
</tr>
<tr class="trEven">
<td>SubTotal:</td>
<td class="algn_R">
<input name="perticketCost" type="hidden" id="perticketCost" value="<?php echo $row_rsTickPurchase['ticketCost1']; ?>" />
<input name="ticketName" type="hidden" id="ticketName" value="<?php echo $row_rsTickPurchase['ticketName']; ?>" />
<input name="ticketID" type="hidden" id="ticketID" value="<?php echo $row_rsTickPurchase['ticketID']; ?>" />
$ <input name="ticketCost" type="text" id="ticketCost" size="12" readonly="true" /></td>
</tr>
<?php } while ($row_rsTickPurchase = mysql_fetch_assoc($rsTickPurchase)); ?>
<tr class="trOdd">
<td>TOTAL:</td>
<td class="algn_R">$
<input name="total" type="text" id="total" size="12" /></td>
</tr>
<tr>
<td colspan="2">Confirm your selection and proceed to Step 6</td>
</tr>
<tr class="trbtn">
<td colspan="2"><input name="userEmail" type="hidden" id="userEmail" value="<?php echo $_SESSION['email']; ?>" />
<input name="step" type="hidden" id="step" value="6" />
<input name="Submit" type="submit" class="loginBtn" value="Confirm" /></td></tr>
</table>
</form>
The calc function is called onLoad and during user input with onkeyup. I'd really appreciate some tips as to how to tackle this one. Currently I'm working on how to get the field names for each form field unique via the php loop which populates the form.
View 2 Replies
View Related
Oct 12, 2011
I am trying to execute an .exe file on client side using javascript, say i want to run an pbrush or calc on client side click using JAVASCRIPT..
I tried this by embedding the following in source page of my web application(ASP.NET)
But i am getting an script error called Automation Server can't create an object
View 3 Replies
View Related
Oct 12, 2009
I have a mortgage calc that is adding an extra decimal place to my interest rate. To see this in action go to: [URL]
Change the interest rate to 7.5
Click Calculate Payment
Click Create Amortization Chart
On the following screen you'll see a recap of your data and the interest rate will now say 7.55. Same thing happens if you enter 6.2. Next screen shows 6.22/. I've attached the html and js files in a zip.
View 2 Replies
View Related
Jul 23, 2005
I have an array of input text boxes (txtDOBn) where n is created at
load. On the onchange event I want to calc the age and show in adjacent
input text boxes that are readonly and also arrays (an age calced for
each DOB entered). I was going to use the datediff function in vbscript
to do the calc. Code:
View 12 Replies
View Related