views:

24

answers:

1

I am completely stuck on how to finish this problem... the question goes...

Write a function quality Points that inputs a student’s average and returns 4 if the stu¬dent'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.

...and 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.

+2  A: 

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.

Greg