PDA

View Full Version : generating table


crazy4youbaby
10-18-2004, 02:44 PM
hey, how can i make a table that has rows according to what user inputs in the number of Process?? table should have 3 columns (No. of Process, Burst Time, Ariival Time)

for example, user input 5 as the number of process, he should enter burst time for each process as well as the arrival time. after that, when user click the button named "generate table", the output should be like a table having 5 rows, 3 columns.. displaying the process number with its corresponding burst time and arrival time..

please help.. urgent.. thanks in advance!!

here is my code.. just edit it.


<html>

<script= text/javascript>

// ENTER PROCESS NUMBER

function enterProc()
{
var mess='Minimum Number of Process: 2\nMaximum number of Process: 10';
alert(mess);
a=1;
while(a==1)
{
numProcess=prompt('Enter number of Process:','')
if (numProcess>=2 && numProcess<=10)
a=0;
else
alert("Error: " + '\n' + mess)
}
document.buttonForm.processBtn.disabled="disabled";
document.buttonForm.burstBtn.disabled="";
}


// ENTER BURST TIME

function enterBurst()
{
var burst = new Array()
for(var i=0;i<numProcess;i++)
{
burst[i]=prompt('PROCESS # '+(i+1)+'\nEnter Burst Time:','')
}
document.buttonForm.burstBtn.disabled="disabled";
document.buttonForm.arrivalBtn.disabled="";
}


// ENTER ARRIVAL TIME

function enterArrival(){
var arrival = new Array()
for(var i=0;i<numProcess;i++)
{
arrival[i]=prompt('PROCESS # '+(i+1)+'\nEnter Arrival Time:','')
}
document.buttonForm.arrivalBtn.disabled="disabled";
document.buttonForm.tableBtn.disabled="";
document.buttonForm.ganttBtn.disabled="";
document.buttonForm.cpuUtiBtn.disabled="";
document.buttonForm.truPutBtn.disabled="";
document.buttonForm.turnAroundBtn.disabled="";
document.buttonForm.w8timeBtn.disabled="";
}

// GENERATE TABLE
// THIS WILL BE THE FUNCTION TO BE CALLED
// AFTER CLICKING THE "GEN. TABLE" BUTTON..

</script>

<body>
<form name="buttonForm">
<input type="button" value="Enter Process Number" name="processBtn" onclick="enterProc()"><br>
<input type="button" value="Enter Burst Time" name="burstBtn" onclick="enterBurst()" disabled="disabled"><br>
<input type="button" value="Enter Arrival Time" name="arrivalBtn" onclick="enterArrival()" disabled="disabled"><br>
<input type="button" value="Generate Table" name="tableBtn" onclick="genTable()" disabled="disabled"><br>
</form>
</body>
</html>

Willy Duitt
10-18-2004, 03:21 PM
please help.. urgent.. thanks in advance!!

Urgent?? Does this mean you are willing to pay?
If so, you may wish to post in the Work Offers and Requests (http://www.codingforums.com/forumdisplay.php?f=36) forum outling how much you are willing to spend...

Or, you could try looking here (http://www.webdeveloper.com/forum/showthread.php?s=&threadid=46834), here (http://www.webxpertz.net/forums/showthread.php?t=30640) or here (http://www.sitepoint.com/forums/showthread.php?t=203202)...

.....Willy

jbot
10-18-2004, 03:41 PM
Urgent?? Does this mean you are willing to pay?

probably not, since he only extended his gratitude in advance.

anyway, crazy, unless you're using a trusted application (Moz- or HTA-based) then it's not really advisable to have your interface built using JS. you're really much better using serverside languages to do this, even tho it means another round trip to the server. 10% of users (including me) have no JS support, therefore functionality such as you've suggested would not work.

however, if you really must use JS, then you should check out DOM methods for table creation, such as createElement, setAttribute, and appendChild. hope that helps :)