I will have three text fields; all numbers.
1st A
2nd 4*B
3rd C
I need to divide the above by 6.
The results show display in a separate results text field
10 2046
Please show us the code you're using. Also, you will need to explain your question in more detail because I'm not sure what you're trying to do.
I need this for both HTML/JAVASCRIPT and Android Java - function estimate(Opt,ML,Pess, Res)
-
{
-
var four = 4;
-
var denominator = 6;
-
var ML = ML*4;
-
var numerator = Opt + ML + Pess;
-
var n1 = 0;
-
var n2 = 0;
-
var n3 = 0;
-
return Res = numerator / denominator;
-
if (document.getElementById('Opt').value != "")
-
n1 = parseInt(document.getElementById('Opt').value);
-
if (document.getElementById('ML').value != "")
-
n2 = parseInt(document.getElementById('ML').value);
-
if (document.getElementById('Pess').value != "")
-
n3 = parseInt(document.getElementById('Pess').value);
-
-
-
}
-
-
-
function calc() {
-
var Res = document.getElementById('Res');
-
Res.value = estimate(document.getElementById('Res').value);
-
-
</script>
-
-
</head>
-
<body>
-
<p style="text-align: center; font-size: xx-large; font-style: normal; font-variant: small-caps; font-weight: bold; color: #2D7176;">Pert Calculator</p>
-
<div style="position: relative; width: 955px; left: 285px; top: 0.08px; height: 87.28px;">
-
<label style="font-size: xx-large; font-style: oblique; text-align: center; width: 1010px; position: relative; left: 0px; top: 0px;">This PERT application will help you estimate PERT. The formula for PERT is ((Optimistic + (4 * Most Likely) + Pessimistic) / by 6)</label>
-
</div>
-
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 70.93px; font-size: x-large; color: #937B62;">Optimistic</label>
-
<label style="position: relative; left: 105.00px; top: 71.93px; font-size: large;">Most preferred</label>
-
<input id="Opt" type="text" style="position: relative; width: 276px; height: 28px; left: 401.16px; top: 79.08px;">
-
</div>
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 120.93px; font-size: x-large; color: #937B62;">Most Likely</label>
-
<label style="position: relative; left: 105.00px; top: 121.93px; font-size: large;">More than likely the case</label>
-
<input id="ML" type="text" style="position: relative; width: 276px; height: 28px; left: 308.88px; top: 124.08px;">
-
</div>
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 170.93px; font-size: x-large; color: #937B62;">Pessimistic</label>
-
<label style="position: relative; left: 105.00px; top: 171.93px; font-size: large;">Worst Case</label>
-
<input id="Pess" type="text" style="position: absolute; width: 276px; height: 28px; left: 640px; top: 451px;">
-
</div>
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 226.93px; font-size: x-large; color: #937B62;">Result</label>
-
<input id="Res" type="text" style="position: relative; width: 276px; height: 28px; left: 570.67px; top: 226.35px;" readonly="" >
-
</div>
-
-
<div style="height: 80.44px;">
-
<button value="Calculate" onclick="calc()" style="position: relative; width: 165px; height: 54.27px; left: 80px; top: 273.08px; font-size: x-large;" type="button">Calculate</button>
-
</div>
-
-
<div style="height: 40px;">
-
<button id="reset" type="reset" value="Reset" style="position: relative; width: 125px; height: 45px; left: 1010px; top: 243.08px; font-size: x-large;">Reset</button>
-
</div>
-
-
<div>
-
<img src="/CBA%20Logo%20Pert%20Calculator.fw.png" style="position: relative; left: 4px; top: -411.92px;">
-
</div>
-
-
-
-
</body>
-
</html>
Need what? You haven't explained clearly what it is you want. I find your first post confusing. And your post with the code seems to have little to no relation to your first.
I cannot get the result text field to populate correctly.
There are four text fields; all numbers.
The user would enter these numbers.
Text field 1: Opt
Text field 2: 4*ML (4 times X)
Text field 3: Pess
All three text fields are added together and once added, the total will be divided by 6.
Text field 4: Is the results of the first three fields
For one thing, your javascript code can't even run. You didn't close your calc function. You also call your estimate function but only pass one parameter when it expects 4. And you return from the estimate function even though there's more code below it.
I have modified the code but the results are still not reflecting the result text field: - function estimate(Opt,ML,Pess, Res)
-
{
-
var Opt = parseInt(document.getElementById('Opt').value);
-
var ML = parseInt(document.getElementById('ML').value);
-
var Pess = parseInt(document.getElementById('Pess').value);
-
-
var Res = ((Opt + (4 * ML) + Pess)/6);
-
document.getElementById("showsum").innerHTML = Res;}
-
</script>
-
-
</head>
-
<body>
-
<p style="text-align: center; font-size: xx-large; font-style: normal; font-variant: small-caps; font-weight: bold; color: #2D7176;">Pert Calculator</p>
-
<div style="position: relative; width: 955px; left: 285px; top: 0.08px; height: 87.28px;">
-
<label style="font-size: xx-large; font-style: oblique; text-align: center; width: 1010px; position: relative; left: 0px; top: 0px;">This PERT application will help you estimate PERT. The formula for PERT is ((Optimistic + (4 * Most Likely) + Pessimistic) / by 6)</label>
-
</div>
-
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 70.93px; font-size: x-large; color: #937B62;">Optimistic</label>
-
<label style="position: relative; left: 105.00px; top: 71.93px; font-size: large;">Most preferred</label>
-
<input id="Opt" type="text" style="position: relative; width: 276px; height: 28px; left: 401.16px; top: 79.08px;">
-
</div>
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 120.93px; font-size: x-large; color: #937B62;">Most Likely</label>
-
<label style="position: relative; left: 105.00px; top: 121.93px; font-size: large;">More than likely the case</label>
-
<input id="ML" type="text" style="position: relative; width: 276px; height: 28px; left: 308.88px; top: 124.08px;">
-
</div>
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 170.93px; font-size: x-large; color: #937B62;">Pessimistic</label>
-
<label style="position: relative; left: 105.00px; top: 171.93px; font-size: large;">Worst Case</label>
-
<input id="Pess" type="text" style="position: absolute; width: 276px; height: 28px; left: 640px; top: 451px;">
-
</div>
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 226.93px; font-size: x-large; color: #937B62;">Result</label>
-
<input id="Res" type="text" style="position: relative; width: 276px; height: 28px; left: 570.67px; top: 226.35px;" readonly="" >
-
-
</div>
-
-
<div style="height: 80.44px;">
-
<button value="Calculate" onclick="estimate()" style="position: relative; width: 165px; height: 54.27px; left: 80px; top: 273.08px; font-size: x-large;" type="button">Calculate</button>
-
-
</div>
-
-
<div style="height: 40px;">
-
<button id="reset" type="reset" value="Reset" style="position: relative; width: 125px; height: 45px; left: 1010px; top: 243.08px; font-size: x-large;">Reset</button>
-
</div>
-
-
</body>
-
</html>
-
Your estimate function is still expecting 4 parameters but now you're passing no parameters at all. You also have no element with an id of showsum.
Hi Rabbit, I think I have fixed that but the fields are not adding up together, they are just stacking on each other. So if I enter values: 14, 15, and 16, the result is 141516.
Please tell me how to add the fields and then divide -
function estimate(Opt, ML, Pess, Res)
-
{
-
var Opt = parseInt(document.getElementById('Opt').value);
-
var ML = parseInt(document.getElementById('ML').value * 4);
-
var Pess = parseInt(document.getElementById('Pess').value);
-
var Res = parseInt(document.getElementById('Res').value);
-
-
document.getElementById('Res').value = (document.getElementById("Opt").value + document.getElementById('ML').value + document.getElementById('Pess').value / 6);
-
</script>
-
-
</head>
-
<body>
-
<p style="text-align: center; font-size: xx-large; font-style: normal; font-variant: small-caps; font-weight: bold; color: #2D7176;">Pert Calculator</p>
-
<div style="position: relative; width: 955px; left: 285px; top: 0.08px; height: 87.28px;">
-
<label style="font-size: xx-large; font-style: oblique; text-align: center; width: 1010px; position: relative; left: 0px; top: 0px;">This PERT application will help you estimate PERT. The formula for PERT is ((Optimistic + (4 * Most Likely) + Pessimistic) / by 6)</label>
-
</div>
-
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 70.93px; font-size: x-large; color: #937B62;">Optimistic</label>
-
<label style="position: relative; left: 105.00px; top: 71.93px; font-size: large;">Most preferred</label>
-
<input id="Opt" type="text" style="position: relative; width: 276px; height: 28px; left: 401.16px; top: 79.08px;">
-
</div>
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 120.93px; font-size: x-large; color: #937B62;">Most Likely</label>
-
<label style="position: relative; left: 105.00px; top: 121.93px; font-size: large;">More than likely the case</label>
-
<input id="ML" type="text" style="position: relative; width: 276px; height: 28px; left: 308.88px; top: 124.08px;">
-
</div>
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 170.93px; font-size: x-large; color: #937B62;">Pessimistic</label>
-
<label style="position: relative; left: 105.00px; top: 171.93px; font-size: large;">Worst Case</label>
-
<input id="Pess" type="text" style="position: absolute; width: 276px; height: 28px; left: 640px; top: 451px;">
-
</div>
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 226.93px; font-size: x-large; color: #937B62;">Result</label>
-
<input id="Res" type="text" style="position: relative; width: 276px; height: 28px; left: 570.67px; top: 226.35px;" readonly="" >
-
<object id="divide"></object>
-
<object id="add"></object>
-
</div>
-
-
<div style="height: 80.44px;">
-
<button value="Calculate" onclick="estimate()" style="position: relative; width: 165px; height: 54.27px; left: 80px; top: 273.08px; font-size: x-large;" type="button">Calculate</button>
-
-
</div>
-
-
<div style="height: 40px;">
-
<button id="reset" type="reset" value="Reset" style="position: relative; width: 125px; height: 45px; left: 1010px; top: 243.08px; font-size: x-large;">Reset</button>
-
</div>
-
-
</body>
-
</html>
-
You made changes that I didn't say to make. Go back and make only the those two changes I mentioned.
Please read 'Rabbit's request... -
<html>
-
<head>
-
<title> </title>
-
<script type="text/javascript">
-
function estimate() {
-
var Opt = parseInt(document.getElementById('Opt').value);
-
var ML = parseInt(document.getElementById('ML').value);
-
var Pess = parseInt(document.getElementById('Pess').value);
-
var Res = ((Opt + (4 * ML) + Pess)/6);
-
document.getElementById("showsum").value= Res.toFixed(2);
-
}
-
</script>
-
-
</head>
-
<body>
-
<form id="myForm" action="" method="post" onsubmit="return false">
-
-
<p style="text-align: center; font-size: xx-large; font-style: normal; font-variant: small-caps; font-weight: bold; color: #2D7176;">Pert Calculator</p>
-
<div style="position: relative; width: 955px; left: 285px; top: 0.08px; height: 87.28px;">
-
<label style="font-size: xx-large; font-style: oblique; text-align: center; width: 1010px; position: relative; left: 0px; top: 0px;">
-
This PERT application will help you estimate PERT. The formula for PERT is ((Optimistic + (4 * Most Likely) + Pessimistic) / by 6)</label>
-
</div>
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 70.93px; font-size: x-large; color: #937B62;">Optimistic</label>
-
<label style="position: relative; left: 105.00px; top: 71.93px; font-size: large;">Most preferred</label>
-
<input id="Opt" type="text" style="position: relative; width: 276px; height: 28px; left: 401.16px; top: 79.08px;">
-
</div>
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 120.93px; font-size: x-large; color: #937B62;">Most Likely</label>
-
<label style="position: relative; left: 105.00px; top: 121.93px; font-size: large;">More than likely the case</label>
-
<input id="ML" type="text" style="position: relative; width: 276px; height: 28px; left: 308.88px; top: 124.08px;">
-
</div>
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 170.93px; font-size: x-large; color: #937B62;">Pessimistic</label>
-
<label style="position: relative; left: 105.00px; top: 171.93px; font-size: large;">Worst Case</label>
-
<input id="Pess" type="text" style="position: absolute; width: 276px; height: 28px; left: 640px; top: 451px;">
-
</div>
-
-
<div>
-
<label style="position: relative; left: 85.00px; top: 226.93px; font-size: x-large; color: #937B62;">Result</label>
-
<input id="showsum" type="text" style="position: relative; width: 276px; height: 28px; left: 570.67px; top: 226.35px;" readonly="" >
-
-
</div>
-
-
<div style="height: 80.44px;">
-
<button value="Calculate" onclick="estimate()"
-
style="position: relative; width: 165px; height: 54.27px; left: 80px; top: 273.08px; font-size: x-large;" type="button">
-
Calculate</button>
-
-
</div>
-
-
<div style="height: 40px;">
-
<button id="reset" type="reset" value="Reset"
-
style="position: relative; width: 125px; height: 45px; left: 1010px; top: 243.08px; font-size: x-large;">
-
Reset</button>
-
</div>
-
</form>
-
</body>
-
</html>
-
Note: You need a <form> tag for the 'Reset' to work.
Also, your 'showsum' is a .value, not a .innerHTML
Finally, no need to pass parameters in the 'estimate()' function.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Dan |
last post by:
Can anyone offer suggestions on how to do this or if it is possible?
I have a form that uses a drop down box and 2 text fields.
What I am trying to do is have the value of each text box set by...
|
by: Sehboo |
last post by:
Hi,
I have a webpage with two text fields, and a button. Text fields are
for Names and phonenumber. Once user clicks on the button, the form
does some processing.
Problem is that I have a...
|
by: Frustrated Developer via DotNetMonster.com |
last post by:
I have posted a couple times on here already and found the user community to
be very helpful. I took on a project before I realized how difficult a time
I'm having working with a database....
|
by: Ennio-Sr |
last post by:
Hi all!
After a very long struggle I finally succeded in transferring my old
*.dbf file and the relating *.dbt (alias memo fields) to a pg table.
For the time being I put the memo field in a...
|
by: John Smith |
last post by:
I have two text fields in a table. One is Height, one is width. Some
examples of what might be each field:
Height Width
35' 35'
8' 6'
4 to 6...
|
by: Tzanko |
last post by:
As we all know, there is a 8060 bytes size limit on SQL Server rows. I
have a table which requires a number of text fields (5 or 6). Each of
these text fields should support a max of 4000...
|
by: letam |
last post by:
Hello, Thank you in advance for any help, it will be most appreciated!
I need to be able to disable several text fields, until the user enters a value in a certain text field. Once they enter a...
|
by: parnellsquare |
last post by:
I am a software tester - the developers I am working with are telling me there is no way to allow users to enter text that includes punctuation marks like apostrophes, quate marks, semi-colons,...
|
by: Kassimu |
last post by:
Hi guys out there,
There is this database Iam creating, I have a table with 40 fields among which there are Date/time, Text, Number, Memo and Yes/No fields and I have created the form bound to that...
|
by: gcoaster |
last post by:
Hello Group,
I was wondering if anyone out there can help me
I have a form
Unbound List Box Control on the form
The row source is a built-in query.
I was wondering if there is anyway to...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |