Dear Sir,

I have following code

    <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")
    alert("Amount 2 is greater")
    form1.text3.value=("Amount 2 is greater")

    <body onload="form1.text1.focus()">  
    <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>
    <h4>Enter any digit in text1 and text2 and see result in text3</h4>

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

3 Years
Discussion Span
Last Post by diafol

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.