Once you click on the refresh or new test button the values will get changed.
Source Code:
<%@page import="java.util.ArrayList" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"%>
<html>
<head>
<%! ArrayList test=null;
int count=0;
%>
<%
test=new ArrayList();
String[] values=new String[2];
values[0]="20";
values[1]="2";
test.add(values);
String[] values1=new String[2];
values1[0]="30";
values1[1]="3";
test.add(values1);
String[] values3=new String[2];
values3[0]="40";
values3[1]="4";
test.add(values3);
String[] values4=new String[2];
values4[0]="50";
values4[1]="5";
test.add(values4);
count=test.size();
%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript">
var strToTest=new Array();
var DBduration=new Array();
var strToTestType = "";
var texte="";
var testDuration="";
var intToTestCnt = <%=count%>;
<% if(test!=null){
for(int k=0;k<test.size();k++){
String[] temp1=(String[])test.get(k);
String data=temp1[0];
int duration=(Integer.parseInt(temp1[1]))*60;
%>
strToTest.push("<%=data%>");
DBduration.push("<%=duration%>");
<%
}
}
%>
function newTest() {
location.reload(true);
}
</script>
</head>
<body>
<form action="#" method="post">
<tr><td>Count value:</td>
<td> <input type="text" name="count" id="count"/></td></tr>
<br/> <br/>
<tr><td>duration:</td>
<td><input type="text" name="duration" id="duration" ></td></tr>
<tr></tr> <tr></tr><br/><br/><br/>
<tr><td><input type="Submit" value="new Test" onclick="newTest();" /></td></tr>
<script type="text/javascript">
randNum = Math.floor((Math.random() * 10)) % intToTestCnt;
strToTestType = strToTest[randNum];
testDuration=DBduration[randNum];
document.getElementById("count").value=strToTestType;
document.getElementById("duration").value=testDuration;
</SCRIPT>
</form>
</body>
</html>
----------------------------------- @@@@@@@@@@@@@-----------------------------
No comments:
Post a Comment