<html>
<head>
<script type = "text/javascript">
var i = prompt("[1]First Come First Serve \n" + "[2] Shortest Job Next \n" + "[3] Priority \n");
// first come first server(FCFS) //
var fcfsjn = new Array();
var cb1 = new Array();
if(i == "1")
{
var i1 = prompt("First Come First Serve \n" + "Enter number of jobs:")
for(var i2 = 0; i2<i1; i2++)
{
fcfsjn[i2] = prompt("JN:" + " ");
}
for(var i3 = 0; i3<i1; i3++)
{
cb1[i3] = prompt("CB:" + " ");
}
}
for (var i4=0; i4<i1; i4++)
{
document.write(fcfsjn[i4]+ "<br>");
}
for (var i5=0; i5<i1; i5++)
{
document.write(cb1[i5] + "<br>");
}
</script>
</head>
<body>
<table border ="border">
<caption>
<tr>
<th colspan ="4"> First Come First Server </caption>
</tr>
<tr>
<th> JN </th>
<th> AT </th>
<th> CB </th>
<th> ST </th>
<th> FT </th>
<th> TAT </th>
<th> WT </th>
</tr>
<tr>
<th> A </th>
<td> fcfsjn[0] </td>
<td> fcfsjn[1] </td>
<td> fcfsjn[2] </td>
<td> fcfsjn[3] </td>
</tr>
<tr>
<th> B </th>
<td> cb1[0] </td>
<td> cb1[1] </td>
<td> cb1[2] </td>
<td> cb1[3] </td>
</tr>
<tr>
<th> C </th>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
2 Replies - 595 Views - Last Post: 23 January 2012 - 10:41 PM
Topic Sponsor:
#1
javascript non-pre emptive scheduling - array and html table
Posted 20 January 2012 - 07:54 PM
good day! im having trouble with my html table. i want to put may javascript array output inside the html table. is this possible? can someone give me some hint on how to put it inside the table? here is the code so far.
Replies To: javascript non-pre emptive scheduling - array and html table
#2
Re: javascript non-pre emptive scheduling - array and html table
Posted 21 January 2012 - 02:07 AM
it’s possible, but normally it’s done differently (recommendation: drop the use of document.write() until you understand what it does).
what you would need to do is creating the rows (and cells) to be inserted on the fly. useful functions for that are
- HTMLTableElement.insertRow() & HTMLTableRowElement.insertCell()
or
- document.createElement() & Node.appendChild()
what you would need to do is creating the rows (and cells) to be inserted on the fly. useful functions for that are
- HTMLTableElement.insertRow() & HTMLTableRowElement.insertCell()
or
- document.createElement() & Node.appendChild()
#3
Re: javascript non-pre emptive scheduling - array and html table
Posted 23 January 2012 - 10:41 PM
DONE! thank you sir Dormilich for the help.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|