{"id":29,"date":"2019-09-17T16:50:48","date_gmt":"2019-09-17T11:20:48","guid":{"rendered":"https:\/\/www.kwikapi.com\/article\/?p=29"},"modified":"2019-09-17T16:51:07","modified_gmt":"2019-09-17T11:21:07","slug":"show-hide-div-in-form-based-on-selected-option-using-javascript","status":"publish","type":"post","link":"https:\/\/www.kwikapi.com\/article\/show-hide-div-in-form-based-on-selected-option-using-javascript\/29\/","title":{"rendered":"Show\/Hide Div in Form based on selected option using javascript"},"content":{"rendered":"\n<p>Hi Friends,<\/p>\n\n\n\n<p> I am going to write a script to Show\/hide div contents using Javascript and HTML.<\/p>\n\n\n\n<p>In this article, I will write codes and you can check it on your localhost\/web page.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE HTML>\n&lt;html>\n&lt;head>\n\t&lt;meta http-equiv=\"content-type\" content=\"text\/html\" \/>\n\t&lt;meta name=\"author\" content=\"Owner\" \/>\n\n\t&lt;title>Untitled 1&lt;\/title>\n    \n&lt;script type=\"text\/javascript\" src=\"https:\/\/code.jquery.com\/jquery-1.9.1.js\">&lt;\/script>\n&lt;script type=\"text\/javascript\">\n\n    $(window).load(function(){\n      \n$('#dbType').on('change',function(){\n    if( $(this).val()===\"other\"){\n    $(\"#otherType\").show()\n    }\n    else{\n    $(\"#otherType\").hide()\n    }\n});\n\n    });\n&lt;\/script>\n\n&lt;\/head>\n&lt;body>\n    &lt;label for=\"db\">Choose type&lt;\/label>\n&lt;select name=\"dbType\" id=\"dbType\">\n   &lt;option>Choose Database Type&lt;\/option>\n   &lt;option value=\"oracle\">Oracle&lt;\/option>\n   &lt;option value=\"mssql\">MS SQL&lt;\/option>\n   &lt;option value=\"mysql\">MySQL&lt;\/option>\n   &lt;option value=\"other\">Other&lt;\/option>\n&lt;\/select>\n\n&lt;div id=\"otherType\" style=\"display:none;\">\n&lt;label for=\"specify\">Specify&lt;\/label>\n&lt;input type=\"text\" name=\"specify\" placeholder=\"Specify Databse Type\"\/>\n&lt;\/div>\n\n\n&lt;\/body>\n&lt;\/html><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Hi Friends, I am going to write a script to Show\/hide div contents using Javascript and HTML. In this article, I will write codes and you can check it on your localhost\/web page.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[5],"_links":{"self":[{"href":"https:\/\/www.kwikapi.com\/article\/wp-json\/wp\/v2\/posts\/29"}],"collection":[{"href":"https:\/\/www.kwikapi.com\/article\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kwikapi.com\/article\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kwikapi.com\/article\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kwikapi.com\/article\/wp-json\/wp\/v2\/comments?post=29"}],"version-history":[{"count":6,"href":"https:\/\/www.kwikapi.com\/article\/wp-json\/wp\/v2\/posts\/29\/revisions"}],"predecessor-version":[{"id":35,"href":"https:\/\/www.kwikapi.com\/article\/wp-json\/wp\/v2\/posts\/29\/revisions\/35"}],"wp:attachment":[{"href":"https:\/\/www.kwikapi.com\/article\/wp-json\/wp\/v2\/media?parent=29"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kwikapi.com\/article\/wp-json\/wp\/v2\/categories?post=29"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kwikapi.com\/article\/wp-json\/wp\/v2\/tags?post=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}