Khead> meta charset=utf-8> Ktitle>Example for Assignment 3, Problem k/title> K/script>

The

border-1 width-508> The table

GoK/p example.js function start () var pobj-document.getElementById ( pid), tobj-document.getElementById( tid); pobj, innerHTML tobi. innerHTML += += 3;



Another helper on the site helped me solve this problem but sadly I ran into an error here is what I have could I get some assistance on fixing this up please?

———————-HW3a.html—————————

Example for Assignment 3, Problem 1

+ 3/tdxtd 4;” src=”https://files.transtutors.com/cdn/qimg/0b9af91e93494a71b20e756b8045bf67.jpg” aria-describedby=”eei”>

The number is

1 2

Go!

————–HW3a.js——————————-

function start(){
   var rows = prompt( “Number of rows”, 1 ),cols = prompt( “Number of columns”, 1 ),inAr;
  
   inAr = inputArray(rows, cols);
   sumAll( inAr );
   rowSum( inAr );
   colSum( inAr );
}
function inputArray(rows, cols){

   inAr = new Array(rows);

   var tableInner = “”;

   for(i=0; i

   tableInner += “”;

   inAr[i] = new Array(cols);

       for(j=0; j

       var cellValue = prompt(“Enter row ” + i + ” column ” + j + ” value: “);

       inAr[i][j] = cellValue;

       tableInner += “” + cellValue + “”;

       }

       tableInner += “”;

   }

   document.getElementById(“input”).innerHTML += tableInner;

   return inAr;

}

function sumAll(inAr){

   var sum = 0;

   for(int i=0; i

       for(int j=0; j

       sum += inAr[i][j];

       }

   }

   document.getElementById(“sum”).innerHTML += sum;

}

function rowSum(inAr){

   var sum = 0;

   for(int i=0; i

   sum = 0;

       for(int j=0; j

       sum += inAr[j][i];

       }

   sum = parseFloat(sum)/inAr.length;

   document.getElementById(“rowS”).innerHTML += ” + sum + “”;

   }

}

function colSum(inAr){

   var sum = 0;

   for(int i=0; i

   sum = 0;

       for(int j=0; j

       sum += inAr[i][j];

       }

       document.getElementById(“colS”).innerHTML += ” + sum + “”;

   }

}

Part 1 (15 points) For this problem, you need to know a little about the DOM. If an element in our document has an id attribute with value, say, “v”, then we get a reference to an object corresponding to the element (and assign it to a variable obj) with obj-document.getElementById (“v”); We can then assign the element content by assigning to the object’s innerHTML attribute, e.g., obj.innerHTML”An example”: This goes between the opening and closing tags of the element (hence “inner), and it may itself contain markup. We can append content to the end of what is already there with statements such as obj.innerHTML += ” of dynamic content”; As an example, consider the following HTML document and JavaScript script example html Khtml> Khead> meta charset=”utf-8″> Ktitle>Example for Assignment 3, Problem k/title> K/script>

The

border-“1” width-“508”> The table

GoK/p example.js function start () var pobj-document.getElementById ( “pid”), tobj-document.getElementById( “tid”); pobj, innerHTML tobi. innerHTML += += 3; “

” + “3/tdxtd 4”;

1 2



Source link

Leave a Reply

Your email address will not be published.