WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Filtering Client side JavaScript Arrays Using regular expressions
Categories : Java Script Update Picture
Satyan Ranganath
Date : Feb 04th 2000
Grade : 5 of 5 (graded 1 times)
Viewed : 2477
File : a.doc
Images : No Images for this code example.
Search : More code by Satyan Ranganath
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<HTML>
<HEAD>
<SCRIPT type="text/Javascript">

/* Global variable */

var a = new Array(4)
var v_foundarray = new Array(4)

function filldata()
{

        /* Initialize variables */

        var j = 0
        var strHTML = " "

        var v_filterops = new Array()
        var myVar = "<table border='1'>"

        /* Initialize two dimension array */

        for (var i=0; i < 4; i++) {
         a[i] = new Array(4)
         v_foundarray[i] = new Array(4)
        }



        /* Heading */

        v_foundarray[0][0] = "Row"
        v_foundarray[0][1] = "String"
        v_foundarray[0][2] = "Number"
        v_foundarray[0][3] = "Date"

        a[0][0] = "Row"
        a[0][1] = "String"
        a[0][2] = "Number"
        a[0][3] = "Date"

        /* Row 1 Data */

        a[1][0] = "1"
        a[1][1] = "Satyan"
        a[1][2] = "1234"
        a[1][3] = "3/4/99"

        /* Row 2 Data */        

        a[2][0] = "2"
        a[2][1] = "Manish"
        a[2][2] = "9012"
        a[2][3] = "5/6/99"

        /* Row 3 Data */

        a[3][0] = "3"
        a[3][1] = "Filter"
        a[3][2] = "4556"
        a[3][3] = "8/7/99"

        for (var i=0; i < 4; i++) {
         var str = "<tr>"
         for (var j=0; j < 4; j++) {
                if (i == 0 )
                 v_filterops[j] = new Option(a[i][j],j)
                 str += "<td>" + a[i][j] + "</td>"
         }
         myVar += str + "</tr>"
        }

        document.all.vals.innerHTML = myVar + "</table>";
        for ( var i=0; i<v_filterops.length;i++)
                document.all.field.options[i] = new Option(v_filterops[i].text,v_filterops
[i].value)
}

function filter()
{
        
        var el = document.all.inpREGEXP.value
        var v_heading = document.all.field.value
        var myVar = "<table border='1'>"
        var found_cntr = 0
        
        var v_regexp = new RegExp(el,"gi")

        switch (v_heading) {
         case "0": /* ROWID */
                        var j=1
                        for (var i=1;i<4;i++) {
                                if ( v_regexp.test(a[i][0]) )
                                {
                                 v_foundarray[j] = a[i]
                                 j++
                                 found_cntr++
                                }        
                        }
                break;
         case "1": /* STRING */
                        var j=1
                        for (var i=1;i<4;i++) {
                                if ( v_regexp.test(a[i][1]) )
                                {                
                                 v_foundarray[j] = a[i]
                                 j++
                                 found_cntr++
                                }        
                        }
                break;
         case "2": /* NUMBER */
                        var j=1
                        for (var i=1;i<4;i++) {
                                if ( v_regexp.test(a[i][2]) )
                                {
                                 v_foundarray[j] = a[i]
                                 j++
                                 found_cntr++                                
                                }        
                        }
                break;
         case "3": /* DATE */
                        var j=1
                        for (var i=1;i<4;i++) {
                                if ( v_regexp.test(a[i][3]) )
                                {
                                 v_foundarray[j] = a[i]
                                 j++
                                 found_cntr++
                                }        
                        }
                break;
        }
        
        for (var i=0; i <= found_cntr; i++) {
         var str = "<tr>"
         for (var j=0; j < 4; j++) {
                 str += "<td>" + v_foundarray[i][j] + "</td>"
         }
         myVar += str + "</tr>"
        }

        document.all.vals.innerHTML = myVar + "</table>"
}
</SCRIPT>

</HEAD>

<BODY onload="filldata()">
        FILTER ON : <SELECT NAME='field'></SELECT>&nbsp;REGULAR EXPRESSION:
<INPUT NAME="inpREGEXP" TYPE="TEXT"> <INPUT TYPE="BUTTON" value="Filter"
Onclick="filter()">
        <hr><br>
        <DIV ID="vals"></DIV>
</BODY>

</HTML>



Email Address Protection (Avoide SPAM)
Categories : Java Script, Email, Encryption
Check if Javascript is Enabled or Disabled - Works in all Browsers
Categories : Java Script, HTML, Web Browsers
Page Loading Message shown during the time your site's page is being loaded.
Categories : HTML, CSS, Java Script
Alert in JavaScript and Trace in Flash Action script are two commands that I find very much useful for tracking and debugging errors in my scripts. Unfortunately, there is no such option in PHP.
Categories : PHP, Java Script, Debugging
Javascript Background Scroller
Categories : Java Script, CSS, HTML
Clock at Status Bar
Categories : Java Script, HTML, Date Time
Get your browser details using javascript
Categories : Java Script, Beginner Guides, Browsers
Remote Scripting: send form POST data to a script and insert the results into a page without refreshing the page.
Categories : PHP, AJAX, HTML and PHP, Java Script
Linked comboboxes with php-mysql & javascript
Categories : PHP, Java Script, Databases, MySQL
PHP3 generated gif / javascript mouseover.
Categories : PHP, Java Script, MySQL
Store, retrieve and delete cookies using JavaScript.
Categories : Java Script, Cookies, Beginner Guides, Cookies
JAVASCRIPT interface class to the eBusiness Charts generatation remote service.
Categories : Java Script, Graphics, Charts and Graphs
Show hide table rows to make dynamic forms
Categories : Beginner Guides, Java Script, Form Processing, HTTP
A simple configuration file editor to ease you life in setting up php applications. Reads variables from a given file automatically and displays current value. New value will be written to file after submit.
Categories : PHP, Filesystem, Regexps, Java Script
Popup window creator for images on the Fly.
Categories : PHP, GD image library, Java Script