in Education by
I wrote the following code to Calculate determinant of a nXn matrix. I could successfully check if the order (i.e. n )entered by the user is valid or not. However I am stuck now: If I enter 3, I must display 9 text boxes and each must be checked. Firstly how do i display in general n^2 text boxes(i.e. n rows and n columns). Secondly how I check each of them individually(i.e. it is a valid entry). code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Javascript App

Determinant of a nxn matrix

This program allows you to compute the determinant of a nxn matrix

Input the order of the matrix

javascript: var order; function verifyorder(){ order=document.getElementById('value').value; if(order>0){ displaydet(); } else{ alert("Sorry, you need to enter a positive integer value, try again"); document.getElementById('error').innerHTML="Sorry, you need to enter a positive integer value, try again"; } } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You will need to dynamically generate the text boxes since you don't know how many there will be in advance. Use the Document Object Model (DOM) for this, or alternatively, use a framework like JQuery which makes the DOM easier to use. In this case, you need to create n * n text fields, and store them in a grid in two distinct senses of "grid". Firstly, you will want to store them in a physical HTML table, so the user sees them as a grid (that answers question 1). Secondly, you will want to store them in a 2D JavaScript array, so your code can manipulate them (that answers question 2). So, use document.createElement("input") to create each text field. Use the setAttribute method to set the attributes of the text field, such as its "value" attribute to store the text inside it (these are the same attributes as you would see in the static HTML source for a text field). Then, store the text fields in a 2D array so you can refer back to them later. You should also be dynamically creating an HTML table (using the DOM), dynamically creating rows (tr) and cells (td), and then inserting into each td the generated text field. Once you have done all that, the user can see all the text fields. When you need to validate them, just refer back to the 2D array you created. Use getAttribute("value") on each of the text fields to get their value back as a string. Then you can validate it as you like.

Related questions

0 votes
    Why is Google AdWords Keyword Planner not displaying actual no of searches?...
asked Mar 5, 2021 in Technology by Editorial Staff
0 votes
    I have followed through some of the threads discussing ouput escaping in XSLT but none seesm to address the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I have followed through some of the threads discussing ouput escaping in XSLT but none seesm to address the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    WAP in java to input 3 numbers from user and print the largest no. among them using nested if. Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    If my post duplicated, please give me references. because i failed finding post that appropriate from my ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    In the HTML of a web app, there is the following code What is actually shown on the page is a string displaying ... . Any help? Thanks. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I would like to ask if I require a Mac for the entire process of the iPhone app development or ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I am pulling information from a Page note from the Facebook API. In the output I get an image URL ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    I am pulling information from a Page note from the Facebook API. In the output I get an image URL ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 11, 2022 in Education by JackTerrance
0 votes
    Is it possible to remove ( not hide using display:none ) some part of HTML from source for mobile ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 15, 2022 in Education by JackTerrance
0 votes
    Using HTML button tag, JavaScript command can be executed by using ____ function 1. "alert('Button1'); 2. "alert(Button1);" 3. "alert('Button1');" 4. "alert('Button");"...
asked Feb 26, 2021 in Technology by JackTerrance
0 votes
    I am exploring Float Label pattern for web page using HTML and CSS. The code was referred from http: ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 27, 2022 in Education by JackTerrance
0 votes
    Which method creates unique fields in the HTML which are not shown to the user? (a) User authentication (b) URL ... JSP & API of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
0 votes
0 votes
    After reading the chapter, I know these points: I know that data gets highlighted after being selected. I know ... entry and editing. Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
...