php - Linked metabox options -
is possible build metabox, has several options linked?
say have 3 selections take from, several options:
selection 1: a1, a2, a3, a4
selection 2: b1, b2, b3, b4, b5
selection 3: c1, c2, c3
now, when select a1 option, available options 2 other selections instance b2, b4, b5 , c1. , on, various options.
the thing can create options, , set in description saying alternative can go other options. selected a1 , b1, b1 won't work, shouldn't select it, can write down, think that's not user friendly, , people lazy read, it's easier limit out options.
can done? , how? html manipulating or within php switch
or if-else-if
statements?
you need chained selections, here's simple example
class="snippet-code-js lang-js prettyprint-override">$("#main").change(function(){ $('.chain').fadeout('slow'); switch( $(this).val() ){ case 'tutorials': $('#tutorials').fadein('fast'); break; case 'articles': $('#articles').fadein('fast'); break; } });
class="snippet-code-css lang-css prettyprint-override">body { padding:30px; background-color: #d4de8c; } select { float:left; clear:both; margin: 5px; } .chain { display:none; }
class="snippet-code-html lang-html prettyprint-override"><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <select id="main"> <option value="blog">blog</option> <option value="tutorials">tutorials</option> <option value="articles">articles</option> </select> <select id="tutorials" class="chain"> <option value="jquery">javascript » jquery</option> <option value="codeigniter">php » codeigniter</option> <option value="wordpress">php » wordpress</option> <option value="xhtml-css">xhtml/css</option> </select> <select id="articles" class="chain"> <option value="security">articles » security</option> <option value="design">articles » design</option> </select>
and here's example using ajax.
php wordpress meta-boxes
No comments:
Post a Comment