Passing the form Object as a Parameter : Form Demo « Form Control « JavaScript DHTML






Passing the form Object as a Parameter

   

<html> 

<head> 
<title>Beatle Picker</title> 
<script type="text/javascript"> 
function processData(form) { 
    for (var i = 0; i < form.Beatles.length; i++) { 
        if (form.Beatles[i].checked) { 
            break; 
        } 
    } 
    var chosenBeatle = form.Beatles[i].value; 
    var chosenSong = form.song.value; 
    alert(chosenSong + " " + chosenBeatle ); 
} 


function checkSong(songTitle) { 
    var enteredSong = songTitle.value; 
    alert(enteredSong); 
} 
</script> 


</head> 
<body> 


<form name="Abbey Road"> 
Choose your favorite Beatle: 
<input type="radio" name="Beatles" id="Beatles1" value="John Lennon" checked="true" />John 
<input type="radio" name="Beatles" id="Beatles2" value="Paul McCartney" />Paul 
<input type="radio" name="Beatles" id="Beatles3" value="George Harrison" />George 
<input type="radio" name="Beatles" id="Beatles4" value="Ringo Starr" />Ringo 
<p>Enter the name of your favorite Beatles song:<br /> 
<input type="text" name="song" id="song" value="value" onchange="checkSong(this)" /></p> 
<p><input type="button" name="process" id="process" value="Process" onclick="processData(this.form)" /></p> 
</form> 
</body> 
</html> 

   
    
    
  








Related examples in the same category

1.Computes the french VAT and amounts including all taxes, and converts a currency into Euro
2.A one of everything HTML form
3.JavaScript Loan Calculator
4.Greeting card genertor
5.Online test
6.Searchengine MS IE
7.Collapsing Forms
8.Set font size with form control
9.Set font color with form control
10.Change string to big, bold, fixed with form control
11.Change string to italics, small, strike with form control
12.Change string to subscript and superscript with form control
13.Create a link with value in form controls
14.Passing a Text Object (as this) to the Function