#native_company# #native_desc#
#native_cta#

Remote Scripting with Javascript, IFrames and PHP Page 5

By David Vance
on May 10, 2004

This code also includes a Javascript function called “buildQueryString” to,
obviously, build a query string, but since I only needed to pass a single
search term I omitted that function, and changed this line:

var URL = ‘server.html’ + buildQueryString(theFormName);

…to this line:

var URL = ‘./server.php?s=’+term;
I also added the “term” parameter to the callToServer() function.
Now, each time a user makes a keystroke in the “nameSearch” textbox, the
doSearch() Javascript function is called. That function looks like this:

<?php

function doSearch(theForm

{

    var 
searchTerm theForm.elements['nameSearch'].value;

    if(
searchTerm.length 2

    {

        return;

    }

    var 
s="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ -.";

    if(
s.indexOf(searchTerm.charAt(searchTerm.length-1)) == -1

    {

        return;

    }

    callToServer(searchTerm);  

}

?>



1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9