wordpress - How to restrict options in HTML form based on database contents? -


i'm looking way dynamically restrict options in search form, based on actual database contents. i'm aiming both speed searching , avoiding empty results...

i have no idea terminology use describe (so may searching badly), , don't have many concrete examples, here one: rendition project database search. there 4 "dropdown" form fields, on 20 options under first, on 30 options under second , on.

the behaviour interests me in given example following: if set first field first option [afghanistan], second field's options reduced 2 [afghanistan/cobalt , afghanistan/all]; , vice versa if have clean form sheet , set second field afghanistan/brown there's 2 options under first field [turkey , pakistan].

this elegant way reduce searches manageable sizes. large extent, webshops amazon display behaviour whittling down product categories , allowing ticking boxes brand or quality-rating ("three or more stars" etc), or pack-size , other ad-hoc categories, (a) more advanced need , (b) far instant feedback of example, requiring reload (as expected querying db millions of items; or querying temporary table thousands of initial results).

i have database similar number of product items [a few hundred] , search criteria [five]; in given example field values more "sensitive" (as in, different values drastically increase/reduce database results), combinations of 5 search criteria give few dozens of results there's combinations of 3 search criteria give empty results. [e.g. hardware store, "0--25$" price search contain many dozens of results screws-and-nails, 0 chainsaws.]

so don't want visitors have find "sensitive" values trial , error! in given sample can see sensitivity before eyes, , hence set/release 4 values needed.

it's website written in wordpress, far isn't using external plugins [a load-data-from-csv plugin used read data in, , self-written plugin defines custom post type , taxonomies , forth; presentation self-written theme], default form fields , forth. default database , forth.

what ask complicated procedure. generic answer have work with, ajax. such data manipulation describe, not possible in html level (especially sensitive information, if it's handled @ point, means it's been exposed, , attacker needs press f12 - on windows).

in simple terms:

  1. on keypress, make ajax search request available fields given string.
  2. backend retrieves , provides possible results start given string.
  3. present available values upon ajax success.

and make clear, not html issue. html responsible formatting want present @ point.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -