Question

In: Computer Science

Can someone verify why my code isnt running <!DOCTYPE html> <html> <body bgcolor=aqua text=purple> <script type="text/javascript">...

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>

Solutions

Expert Solution

Dear Student ,

As per requirement submitted above kindly find below solution.

ERROR DETAILS :

  • There is typo error in the function used like funtion
  • Mismatch is function name that is function has the name oldMacVerse() and in the onclick evnet of button used like OlMacVerse()

***********************************************

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.


Related Solutions

<!DOCTYPE html> <html lang="en"> <head>    <title>Form Display Example</title>    <script type="text/javascript">    function display() {...
<!DOCTYPE html> <html lang="en"> <head>    <title>Form Display Example</title>    <script type="text/javascript">    function display() {    dispWin = window.open('','NewWin','toolbar=no,status=no,width=300,height=200')       message = "<ul><li>NAME:" + document.form1.name.value;    message += "<li>ADDRESS:" + document.form1.address.value;    message += "<li>PHONE:" + document.form1.phone.value;    message += "</ul>";    dispWin.document.write(message); } </script> </head> <body>    <h1>Form Display Example</h1>    <p>Enter the following information. When you press the Display button, the data you entered will be displayed in a pop-up.</p>    <form name="form1" method="get" action="">   ...
(C++) Why does my code not continue looping? it only loops twice. Can someone take a...
(C++) Why does my code not continue looping? it only loops twice. Can someone take a look at my code so far: #include <iostream> #include <cmath> #include <cstdlib> #include <string> #include <ctime> using namespace std; void cls(void); void cls(void) { system("cls||clear"); return; } int main() { int BankBalance = 0; char quit; int wager = 0; int inputWager = 0; int sum = 0; int diceRoll = 0; int rollPoint = 0; int point = 0; int dice1 = 0;...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT