Git Product home page Git Product logo

thinker's Introduction

thinker

Use jQuery to give suggestions as typing in an input box

To Use

Include the thinker.js file after jQuery Example <script src="thinker.js"></script> Set thinker to desired input box Example

$("#inputboxid").thinker();

Create a thinker.php file where server side processing is done using the sent data 'key' and 'maxResults' return with key 'items' as a JSON type. Use your own custom way of filtering through data, as in below is searches the array to see if it contains the 'key'. Example thinker.php

  <?php 
  $items_to_check = ["Cheese", "Chili", "Hamburger", "Ham Sandwich"];
  $result = array();
  $txtkey = strtolower($_POST['key']);

  for ($x = 0; $x < sizeof($items_to_check); $x++) {
    $lcase = strtolower($items_to_check[$x]);
    if (strpos($lcase, $txtkey) !== false) { 
        $result[] = $items_to_check[$x];
    }
  // Encode and put key as 'items' so thinker.js can find the data
  echo json_encode(array('items' => $result));
  ?>

Options

To use

  $("#inputboxid").thinker({ backgroundColorHover:'red' } );

  url: link to data source (default 'thinker.php')
  type: GET or POST (default 'POST')
  backgroundColor: (default 'white')
  textColor: (default 'black')
  backgroundColorHover: (default 'blue')
  textColorHover: (default 'white')
  minLength: Minimun characters needed before searching (default 1)
  maxResults: Max results to show (default 10)

v1.0 Released 4/4/17

thinker's People

Contributors

realhades avatar tenniskit avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.