Joe
Joe

Reputation: 11

Comparing input to echo specific output

I'm trying to write a function quality Points that inputs a student’s average and returns 4 if the student's average is 90–100, 3 if the average is 80–89, 2 if the average is 70–79, 1 if the average is 60–69 and 0 if the average is lower than 60. Incorporate the function into a script that reads a value from the user.

The code I have so far is:

<form name="myform">
<script language=javascript>
function output()
{
if (condition)
  {
  document.myform.txtImput
  }

}
</script>

<table border="1">
<tr>
<td>Enter Grade</td><td>

<textarea name=txtImput rows="1" cols="20"></textarea>
</td><td><input name=txtOutput type=button value=Get Quality Points onClick=output()></button></td>
</tr><tr>
<td>Quality Points</td><td>

<textarea name=txtOutput rows="1" cols="20" READONLY></textarea>

</td><td></td>
</tr>
</table>
</form>

I can do the If..Then statements, but I cannot figure out how to change the values of the text area I have named txtOutput.

Upvotes: 0

Views: 276

Answers (1)

Greg
Greg

Reputation: 321786

You can change the textarea like this:

document.forms['myform'].elements['txtOutput'].value = myValue;

You should remove name=txtOutput from your button - you don't need it and it'll just make things difficult.

Upvotes: 2

Related Questions