-2
a = document.CPU.Bfirst.value;

w = document.CPU.Afirst.value;

aa = a + w;

k = aa.sub();

document.write(k);

*I want the sum of the two values in a subscripted form but it only provides a concatenated value instead of the actual sum.

*Other variables:

    a = document.CPU.Bfirst.value;

    b = document.CPU.Bsecond.value;

    c = document.CPU.Bthird.value;

    d = document.CPU.Bfourth.value;

    w = document.CPU.Afirst.value;

    x = document.CPU.Asecond.value;

    y = document.CPU.Athird.value;

    z = document.CPU.Afourth.value;

    e = a - w;

    f = b - x;

    g = c - y;

    h = d - z;

    i = (e + f + g + h)/4;

    aa = a + w;

    bb = aa + x;

    cc = bb + y;

    dd = cc + z;

    j = w.sub();

    k = aa.sub();

    l = bb.sub();

    m = cc.sub();

    n = dd.sub();

*Form part:


    

Enter all needed information:

Process Arrival Time Burst Time A B C D
sfaw
  • 7
  • 2

2 Answers2

2

If your values really are numbers, you can force the conversion with the unary + operator:

aa = +a + +w;

The value property of an <input> node will always give you a string, and the JavaScript + operator really likes strings.

Pointy
  • 405,095
  • 59
  • 585
  • 614
2

If a and w are INT, you can use parseInt()

aa = parseInt(a) + parseInt(w)

If vars are float use parseFloat() instead.

JSFiddle

DrKey
  • 3,365
  • 2
  • 29
  • 46