我寫了下面的代碼來計算nXn矩陣的行列式。 我可以成功檢查用戶輸入的訂單(即n)是否有效。 但是我現在被卡住了: 如果我輸入3,我必須顯示9個文本框,每個文本框都必須檢查。首先,我如何顯示一般n^2個文本框(即n行和n列)。 其次我如何檢查他們每個人(即它是一個有效的條目)。顯示特定號碼。 HTML輸入字段使用javascript
代碼:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Javascript App</title>
<script type="text/javascript" src="app1.js">
</script>
</head>
<body><h1 id="heading1" style="text-align:center; height:auto; width:auto; font-family:'Arial Black', Gadget, sans-serif">Determinant of a nxn matrix</h1>
<p id="paragraph1" style="font-family:'Arial Black', Gadget, sans-serif"> This program allows you to compute the determinant of a nxn matrix</p>
<p>
Input the order of the matrix
<br />
<input type="text" maxlength="3" name="fname" id="value" />
<input type="button" value="submit" onclick="verifyorder()" />
</p>
<p id="error"></p>
<p id="detspace">
<form method="post" action="displaydet()" name="matrix">
</p>
</body>
</html>
的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";
}
}
這是怎麼回答的問題?也許關於你想要做什麼或展示什麼的評論會很好。 – 2014-01-17 15:58:51