dcsimg

Assignment 29: A Possible Answer

This:

<SCRIPT LANGUAGE="javascript">
function TellMe()
{
var number = document.DropDown.DDlinks.selectedIndex;
var answer = document.DropDown.DDlinks.options[number].value;
document.DropDown.Result.value=answer
}
</SCRIPT>

<FORM NAME="DropDown">
<SELECT NAME="DDlinks">
<OPTION SELECTED VALUE="Pick One Please">What Is The Code For?
<OPTION VALUE="<B>text</B>" > Bold
<OPTION VALUE="<I>text</I>"> Italic
<OPTION VALUE="<U>text</U>"> Underline
</SELECT>
<INPUT TYPE="BUTTON" VALUE="Click To Find Out!" onClick="TellMe()">
<INPUT TYPE="text" SIZE="30" NAME="Result">
</FORM>

 

Gives you this:

 

     This is the same code that was used to create the box in Lesson 27, with a few modifications. I added one extra variable, "answer," that was assigned the number the user chose.

     Then I used that to force that menu item's value into the new text box I named "Result."

 

Did You Get It?

 

Back to the Index Page