0

Dear Sir,

I have following code

<html>
  <head>
    <title>Javascript function </title>

<script type="text/javascript">
function hello(){
var xx=eval(form1.text1.value);
var yy=eval(form1.text2.value);

    if (xx>0 && xx>yy){
    alert("Amount 1 is greater")
    form1.text3.value=("Amount 1 is greater")
    }else{
    alert("Amount 2 is greater")
    form1.text3.value=("Amount 2 is greater")
    }
}
    </script>

  </head>
    <body onload="form1.text1.focus()">  
    <center>
    <h1 style="color:#2c80d3 ">Javascript Function</h1>
    <table border="0" cellspacing="1" cellpadding="1" width="25%"> 
        <form name="form1" action="textboxes.php" method="Post">
    <tr><td> First</d><td><input type="text" name="text1"  value=""></td></tr>
      <tr><td> Second</d><td><input type="text" name="text2"  value="" onblur="hello()"></td></tr>
     <tr><td> Result</d><td><input type="text" name="text3"  value="" disabled=""></td></tr>
     <tr><td></td><td align="center"> <input  type="submit" value="Display" name="button1"></td></tr>
    </form>
    </table>
    <h4>Enter any digit in text1 and text2 and see result in text3</h4>
    </center>
    </body>
</html>

It works fine. I want to ask is there any method to convert above javascript function to php function.
I want to make a php function and then call that from textbox's onblur event.

Please help

2
Contributors
1
Reply
13
Views
3 Years
Discussion Span
Last Post by diafol
0

PHP is server-side which means that it won't run in response to an onblur event. You could of course use ajax to run a php script with the onblur event - or even force a form submission with onblur (not recommended).

You can certainly achieve most things server-side, but responsive sites usually make heavy use of js.

I can't see why you'd need this script in php.

Edited by diafol

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.