0

I know this is an extremely basic question, but I just couldn't find anything useful on the internet. I have 2 input boxes and I want calculate that input and put the result in output using submit button and navigating by form id.

<script>
function Calculate()
{

  var resources = GetFieldValue( "Resources" );
  var minutes = GetFieldValue( "Minutes" ); 
  var permin = parseFloat(resources) / 60;
  var result = parseFloat(permin) * parseFloat(minutes);
</script>
2
  • By submit are you talking about POST submit to the server? and by output you're referring to what? Commented Nov 29, 2012 at 14:16
  • @RobertKoritnik No just a basic run in a html file. Commented Nov 29, 2012 at 14:24

2 Answers 2

3
<body>
<input type='text' id='Resources'/>
<input type='text' id='Minutes' onblur='Calculate();'/>
<form name ="testarea" Method="Get" Action="youpage.html" id='form1'>
<input type='text' id='answer' name='ans' />
</form>
</body>
<script>


function Calculate()
{
  var resources = document.getElementById('Resources').value;
  var minutes = document.getElementById('Minutes').value; 
  var permin = parseFloat(resources) / 60;
  document.getElementById('answer').value=parseFloat(permin) * parseFloat(minutes);
  document.form1.submit();
}
</script>

Your form will submit and your answer is in the url like

youpage.html?ans=youranswer
Sign up to request clarification or add additional context in comments.

Comments

1

Use the HTML button tag : http://www.w3schools.com/tags/tag_button.asp

<button onClick="Calculate();" value="calculate">

in the function Calculate instead of GetFieldValue use

document.getElementbyId("Resources").value; 

where

<input type="text" id="Resources">

use

document.getElementbyId("Result").value = result;

to fill in another input element.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.