In: Computer Science
Can someone verify why my code isnt running
<!DOCTYPE html>
<html>
<body bgcolor=aqua text=purple>
<script type="text/javascript">
funtion oldMacVerse(animal, sound)
//Assumes: animal is the name of an animal, sound is the sound it
makes
//Results: displays a version of the song "Old MacDonals Had a
Farm" in outputDiv
{
document.getElementById('outputDiv').innerHTML =
'<p>Old MacDonald had a farm,
E-I-E-I-O.<br>' +
'And on that farm he had a ' + animal + ',
E-I-E-I-O.<br>' +
'With a ' + sound + ' here, and a ' + sound + '-' +
sound +
' there,<br>' + ' here a ' + sound + ', there a
' + sound +
', everywhere a ' + sound + '-' + sound +
'.<br>' +
'Old MacDonald has a farm,
E-I-E-I-O.</p>';
}
</script>
</head>
<body>
<div style="text-align:left">
<h1>Old MacDonald's Farm</h1>
<p>
<input type="button" value="pig"
onclick="OlMacVerse('pig','oink');">
<input type="button" value="dog"
onclick="OlMacVerse('pig','bark');">
<input type="button" value="duck"
onclick="OlMacVerse('pig','quack');">
</p>
<hr>
<div id="outputDiv"></div>
</div>
</body>
</html>
Dear Student ,
As per requirement submitted above kindly find below solution.
ERROR DETAILS :
***********************************************
Here new web page with name "oldmac.html" is created which contains below code.
oldmac.html :
<!DOCTYPE html>
<html>
<body bgcolor=aqua text=purple>
<script type="text/javascript">
function oldMacVerse(animal, sound)
//Assumes: animal is the name of an animal, sound is the sound it makes
//Results: displays a version of the song "Old MacDonals Had a Farm" in outputDiv
{
document.getElementById('outputDiv').innerHTML =
'<p>Old MacDonald had a farm, E-I-E-I-O.<br>' +
'And on that farm he had a ' + animal + ', E-I-E-I-O.<br>' +
'With a ' + sound + ' here, and a ' + sound + '-' + sound +
' there,<br>' + ' here a ' + sound + ', there a ' + sound +
', everywhere a ' + sound + '-' + sound + '.<br>' +
'Old MacDonald has a farm, E-I-E-I-O.</p>';
}
</script>
</head>
<body>
<div style="text-align:left">
<h1>Old MacDonald's Farm</h1>
<p>
<input type="button" value="pig" onclick="oldMacVerse('pig','oink');">
<input type="button" value="dog" onclick="oldMacVerse('pig','bark');">
<input type="button" value="duck" onclick="oldMacVerse('pig','quack');">
</p>
<hr>
<div id="outputDiv"></div>
</div>
</body>
</html>
==================================
Output :Open web page oldmac.html in the browser and will get the screen as shown below.;
Screen showing interface
Screen when pig button is clicked :
Screen when dog button is clicked :
Screen when duck button is clicked :
NOTE :PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.