{"id":408,"date":"2010-11-04T11:43:23","date_gmt":"2010-11-04T15:43:23","guid":{"rendered":"http:\/\/erics-test-lab.com\/?p=408"},"modified":"2010-11-04T11:43:23","modified_gmt":"2010-11-04T15:43:23","slug":"javascript-and-form-style","status":"publish","type":"post","link":"https:\/\/www.esearing.com\/v2010\/2010\/11\/javascript-and-form-style\/","title":{"rendered":"Javascript and form style"},"content":{"rendered":"<p>You can control some form elements CSS style attributes  using Javascript. This comes in handy when trying to highlight errors or disabled fields. You can use a select onChange event to disable\/enable form fields. The style attributes I find most useful are color, border, and backgroundColor (not background-color).<\/p>\n<p><code>&lt;script&gt;<br \/>\nfunction disableitems(myvar){<br \/>\ndocument.form.elementname.disabled=\"false\";<br \/>\ndocument.form.elementname.style.backgroundColor = \"white\";<br \/>\n\/\/ if item is to be disabled<br \/>\nif (myvar == \"yes\"){<br \/>\ndocument.form.elementname.disabled=\"true\";<br \/>\ndocument.form.elementname.style.backgroundColor = \"silver\";<br \/>\n }<br \/>\n}<br \/>\n&lt;\/script&gt;<br \/>\n&nbsp;<br \/>\n&lt;form&gt;<br \/>\n&lt;select name=\"somename\" onChange=\"disableitems(this.value);\"&gt;><br \/>\n&lt;option value=\"no\"&gt;no&lt;\/option&gt;<br \/>\n&lt;option value=\"yes\"&gt;yes&lt;\/option&gt;<br \/>\n&lt;\/select&gt; Disable selector<br \/>\n&lt;input name=\"elementname\" type=\"text\" \/&gt; item to be disabled.<br \/>\n...<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can control some form elements CSS style attributes using Javascript. This comes in handy when trying to highlight errors or disabled fields. You can use a select onChange event to disable\/enable form fields. The style attributes I find most &hellip; <a href=\"https:\/\/www.esearing.com\/v2010\/2010\/11\/javascript-and-form-style\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,8,12],"tags":[],"class_list":["post-408","post","type-post","status-publish","format-standard","hentry","category-code","category-css","category-javascript"],"_links":{"self":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/comments?post=408"}],"version-history":[{"count":0,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/posts\/408\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/media?parent=408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/categories?post=408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esearing.com\/v2010\/wp-json\/wp\/v2\/tags?post=408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}