{"id":1428,"date":"2014-01-13T16:03:55","date_gmt":"2014-01-13T16:03:55","guid":{"rendered":"http:\/\/musilda.cz\/?p=1428"},"modified":"2014-01-13T16:03:55","modified_gmt":"2014-01-13T16:03:55","slug":"jednodussi-vytvareni-formularu-s-funkcemi-selected-a-checked","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/jednodussi-vytvareni-formularu-s-funkcemi-selected-a-checked\/","title":{"rendered":"Jednodu\u0161\u0161\u00ed vytv\u00e1\u0159en\u00ed formul\u00e1\u0159\u016f s funkcemi selected a checked"},"content":{"rendered":"

Ka\u017ed\u00fd kdo k\u00f3duje \u0161ablony, nebo programuje pluginy pro WordPress v\u00ed, jak je otravn\u00e9 ps\u00e1t podm\u00ednky pro kontrolu hodnot v selectech a checkboxech. D\u00edky vestav\u011bn\u00fdm funkc\u00edm WordPressu si m\u016f\u017eete pr\u00e1ci usnadnit a i k\u00f3d formul\u00e1\u0159\u016f bude o dost p\u0159ehledn\u011bj\u0161\u00ed.<\/p>\n

Ob\u011b funkce checked() i selected() funguj\u00ed stejn\u011b, kontroluj\u00ed, zda prom\u011bnn\u00e1 odpov\u00edd\u00e1 podm\u00ednce a pokud ano, vyp\u00ed\u0161\u00ed checked, nebo selected.<\/p>\n

Pod\u00edvejte se na rozd\u00edl mezi:<\/p>\n

\n\n    <option value="1" >1\n    <option value="2" >2\n    <option value="3" >3\n\n<\/pre>\n

a<\/p>\n

\n\n    <option value="1" >1\n    <option value="2" >2\n    <option value="3" >3\n\n<\/pre>\n

Jak je vid\u011bt z k\u00f3du (zdroj. WordPress.org), selected na\u010dte prom\u011bnnou $options[‚foo‘] a pokud se rovn\u00e1 druh\u00e9mu parametru, nap\u0159\u00edklad 1, vyp\u00ed\u0161e selected=“selected“. Krat\u0161\u00ed, rychlej\u0161\u00ed a p\u0159ehledn\u011bj\u0161\u00ed z\u00e1pis. Ocen\u00edte p\u0159edev\u0161\u00edm u slo\u017eit\u011bj\u0161\u00edch formul\u00e1\u0159\u016f.<\/p>\n

Pro checked je pou\u017e\u00edt\u00ed obdobn\u00e9:<\/p>\n

\n<input type="checkbox" name="options[postlink]" value="1"  \/>\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

Ka\u017ed\u00fd kdo k\u00f3duje \u0161ablony, nebo programuje pluginy pro WordPress v\u00ed, jak je otravn\u00e9 ps\u00e1t podm\u00ednky pro kontrolu hodnot v selectech a checkboxech. D\u00edky vestav\u011bn\u00fdm funkc\u00edm WordPressu si m\u016f\u017eete pr\u00e1ci usnadnit a i k\u00f3d formul\u00e1\u0159\u016f bude o dost p\u0159ehledn\u011bj\u0161\u00ed.<\/p>\n","protected":false},"author":1,"featured_media":8523,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[19],"tags":[],"class_list":["post-1428","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-snippety"],"_links":{"self":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/1428"}],"collection":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/comments?post=1428"}],"version-history":[{"count":0,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/posts\/1428\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media\/8523"}],"wp:attachment":[{"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/media?parent=1428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/categories?post=1428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affinite.io\/cs\/wp-json\/wp\/v2\/tags?post=1428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}