Assignment 45: A Possible Answer

This...

<SCRIPT LANGUAGE="javascript">

function Balboa()
{
var num = document.RockyForm.RockyUser.value

var Movie = new Array(6)
Movie[0]="There was no Rocky 0"
Movie[1]="Rocky"
Movie[2]="Rocky II"
Movie[3]="Rocky III"
Movie[4]="Rocky IV"
Movie[5]="Rocky V"

var Outcome = new Array(6)
Outcome[0]="No Outcome"
Outcome[1]="Rocky Lose"
Outcome[2]="Rocky Wins"
Outcome[3]="Rocky Loses, then Wins"
Outcome[4]="Apollo Dies, Rocky Wins"
Outcome[5]="Rocky Wins Street Brawl"

var Rating = new Array(6)
Rating[0]="***** out of 5"
Rating[1]="***** out of 5"
Rating[2]="*** out of 5"
Rating[3]="*** out of 5"
Rating[4]="** out of 5"
Rating[5]="* out of 5"

document.RockyForm.RockyTitle.value=Movie[num]

document.RockyForm.RockyOutcome.value=Outcome[num]
document.RockyForm.RockyRating.value=Rating[num]
}

</SCRIPT>

<FORM NAME="RockyForm">Enter a Rocky Movie Number (1-5):
<INPUT NAME="RockyUser" TYPE="text" SIZE="2">

<INPUT TYPE="button" Value="Tell Me What Happens" onClick="Balboa()"><P>

Movie Rating: <INPUT NAME="RockyRating" TYPE="text" SIZE="26"><BR>
You chose: <INPUT NAME="RockyTitle" TYPE="text" SIZE="26"><BR>
The outcome was: <INPUT NAME="RockyOutcome" TYPE="text" SIZE="26">
</FORM>

 

Gives you this...

Enter a Rocky Movie Number (1-5):

Movie Rating:
You chose:
The outcome was:

     The changes are pretty straightforward. A new array was added for the ratings, plus a text box to receive it. And since we have the new text box, we need to have a new hierarchy statement so that the output of the new array is sent to the right place.

 

Did You Get It?

 

Back to the Index Page