SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Threaded View

  1. #1
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    canada
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    running a PHP script with javascript after a text field focusout event

    Hello,

    I have a text field in my form for a location look up. user enters the zip code and the class returns the city, state, and country and the location information is returned to an array.

    What I like to do is run the location looup script and echo the results before moving to the next step. To do this i needed to inject a little javascript.

    Im not too familiar with JavaScript. I found a small script that works some whate but im not sure how to intergrate the javascript and php script in this case.

    Any help you can provide me would be greatly appreciated.



    PHP Code:
    <!DOCTYPE html>
    <html>
    <head>

      <script src="http://code.jquery.com/jquery-latest.js"></script>
      <script language="javascript" type="text/javascript">
            $(document).ready(function () 
            {    $("#zipcode").focusout(function (event) 
        {       alert("Zip code field must not be empty... how do i run a PHP script here to pull informaiton from the array"); });
             });
    </script>

    </head>
    <body>
          <h2>FocusOut Event Out</h2>
           <br>
           Test field 1: <input type="text" id="test1"  /> <br /><br />    
            Enter zip code: <input type="text" id="zipcode"  /> <br /><br />
           <?php \\PHP script to display :  citystatecountry
        
    echo "<br>" $testArray['City'] . "    " $testArray['State'] . "    " $testArray['Country'];
           
    ?>
    </body>
    </html>
    Last edited by robin01; Dec 15, 2012 at 18:04. Reason: Title change


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •