PHPBuilder - Remote Scripting with Javascript, IFrames and PHP Page 5



RSS Twitter
Articles Html

Remote Scripting with Javascript, IFrames and PHP - Page 5

by: David Vance
|
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);  
}

?>

« Previous Page
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
David Vance

Comment:



Comment:

(Maximum characters: 1200). You have characters left.