Page 1 of 1

Hmm how to do this? Pls check.

Posted: Mon Jun 15, 2009 11:43 pm
by darkmirror
I want to change js file to php .

Here it is .

Js code

Code: Select all

function temp(form)
{
  var a = (form.a.value);
  var b = (form.b.value);
  var c = (form.c.value);
  var d = (form.d.value);
  var e= (form.e.value);
  var f= (form.f.value);
  var g= (form.g.value);
  var h= (form.h.value);
  var i= (form.i.value);
  var j= (form.j.value);
  var k= (form.k.value);
  var l= (form.l.value);
  var m= (form.m.value);
  var n= (form.n.value);
  var o= (form.o.value);
   var aa= (Math.pow(a,3));
   var bb= (Math.pow(b,3));
   var cc= (Math.pow(c,3));
   var dd= (Math.pow(d,3));
   var ee= (Math.pow(e,3));
   var ff= (Math.pow(f,3));
   var gg= (Math.pow(g,3));
   var hh= (Math.pow(h,3));
   var ii= (Math.pow(i,3));
   var jj= (Math.pow(j,3));
   var kk= (Math.pow(k,3));
   var ll= (Math.pow(l,3));
   var mm= (Math.pow(m,3));
   var nn= (Math.pow(n,3));
   var oo= (Math.pow(o,3));  
   var q= (aa+bb+cc+dd+ee+ff+gg+hh+ii+jj+kk+ll+mm+nn+oo+10)
   var p = 0;
   p = (Math.pow(q,1/3)) ;
    form.result.value = p;
}
I want to write the js to php. But i dont know how to..But i have tried this( Doesnt work)::

Code: Select all

<?php
{
    $a = $a;
    $b = $b;
    $c = $c;
    $d = $d;
    $e = $e;
    $f = $f;
    $g = $g;
    $h = $h;
    $i = $i;
    $j = $j;
    $k = $k;
    $l = $l;
    $m = $m;
    $n = $n;
    $o = $o;
 
    $aa = $pow($a,3);
    $bb = $pow($b,3);
    $cc = $pow($c,3);
    $dd = $pow($d,3);
    $ee = $pow($e,3);
    $ff = $pow($f,3);
    $gg = $pow($g,3);
    $hh = $pow($h,3);
    $ii = $pow($i,3);
    $jj = $pow($j,3);
    $kk = $pow($k,3);
    $ll = $pow($l,3);
    $mm = $pow($m,3);
    $nn = $pow($n,3);
    $oo = $pow($o,3);
    
    {$q = $aa + $bb + $cc + $dd + $ee + $ff + $gg + $hh + $ii + $jj + $kk + $ll + $mm + $nn + $oo + 10;
    $result = (pow($q,1/3); }
    echo("Calculation Result: $result");
    }
    
?>
Form Code::
<html>
<head>
<title>Level Calculator</title>
</head>

<body>
<form action="/calc.php" method="post">
<input name="a" type="text" value="0" maxlength="15">
<br/>
<input name="b" type="text" value="0" maxlength="15">
<br/>
<input name="c" type="text" value="0" maxlength="15">
<br/>
<input name="d" type="text" value="0" maxlength="15">
<br/>
<input name="e" type="text" value="0" maxlength="15">
<br/>
<input name="f" type="text" value="0" maxlength="15">
<br/>
<input name="g" type="text" value="0" maxlength="15">
<br/>
<input name="h" type="text" value="0" maxlength="15">
<br/>
<input name="i" type="text" value="0" maxlength="15">
<br/>
<input name="j" type="text" value="0" maxlength="15">
<br/>
<input name="k" type="text" value="0" maxlength="15">
<br/>
<input name="l" type="text" value="0" maxlength="15">
<br/>
<input name="m" type="text" value="0" maxlength="15">
<br/>
<input name="n" type="text" value="0" maxlength="15">
<br/>
<input name="o" type="text" value="0" maxlength="15">
<br/>
<input type="submit" value="Calculate">
<br/>
<input name="result" type="text" value="0" maxlength="30" readonly="readonly" id="result">
</form>
Thanks for reading. And please dont forget to help me...:)

Re: Hmm how to do this? Pls check.

Posted: Mon Jun 15, 2009 11:51 pm
by requinix

Code: Select all

$a = $a;
If I told you my cat was a cat, would you be surprised? How about that the color blue is the same color as blue?

Code: Select all

$a = $_POST["a"];
Use $_POST and $_GET to get data from a form. See also: this.


Also: don't use {}s just for the fun of it. The pair you have in your code don't actually do anything so they shouldn't be there.

Re: Hmm how to do this? Pls check.

Posted: Tue Jun 16, 2009 12:19 am
by darkmirror
Thnx for ur Post and i will try that soon coz i have to go ...:)
i hope it will work!

Re: Hmm how to do this? Pls check.

Posted: Tue Jun 16, 2009 1:52 am
by darkmirror
[s]Oh i am still getting error.
Can you check my site?
It is http://tppcal.netii.net[/s]

Its working now...Yay
Thnx