Which browser is your favorite?

Microsoft Internet Explorer
Netscape Navigator

 

<SCRIPT>

function check(form, browser) {
     form.answer.value = browser;
}

</SCRIPT>

<FORM>
    <INPUT
TYPE="radio" NAME="browser" VALUE="Explorer"  
     
onClick="check(this.form, this.value)">Microsoft Internet Explorer
    <INPUT
TYPE="radio" NAME="browser" VALUE="Netscape"
     
onClick="check(this.form, this.value)">Netscape Navigator
    <INPUT
TYPE="text" NAME="answer">
</FORM>

In this version 2 parameters are passed to the function check(): 1) "the form", & 2) the radio button's value.

By using this approach we don't need to provide the entire path in order to put the browser value into the answer text field.

Advantage: If you decide to put additional Forms in front of our Browser Form, nothing needs to be changed. In the first example we would have to change document.forms[0] to reflect the Forms new position within the document.