2 Replies - 5104 Views - Last Post: 23 January 2012 - 10:41 PM

#1 kelboy03  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 12-October 09

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.
<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>




Is This A Good Question/Topic? 0
  • +

Replies To: javascript non-pre emptive scheduling - array and html table

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3572
  • View blog
  • Posts: 10,414
  • Joined: 08-June 10

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()
Was This Post Helpful? 1
  • +
  • -

#3 kelboy03  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 12-October 09

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1