{"id":802,"date":"2018-02-21T15:33:03","date_gmt":"2018-02-21T15:33:03","guid":{"rendered":"http:\/\/sls.gmu.edu\/web\/?p=802"},"modified":"2018-02-21T16:30:39","modified_gmt":"2018-02-21T16:30:39","slug":"events-planning-form-using-javascript","status":"publish","type":"post","link":"https:\/\/sls.gmu.edu\/web\/2018\/02\/21\/events-planning-form-using-javascript\/","title":{"rendered":"Events Planning Form Using Javascript"},"content":{"rendered":"<p>A short questionnaire to direct users to the right form using Javscript<br \/>\n<code>window.onload = function() { document.getElementById('link1').style.display = 'none'; document.getElementById('link2').style.display = 'none'; }; \/\/Clears div box<\/p>\n<p> var x, y, z; \/\/assigns variables to radio selections<\/p>\n<p> function a1(answer1){ x = answer1; };<br \/>\n function a2(answer2){ y = answer2; };<br \/>\n function a3(answer3){ z = answer3; }; <\/p>\n<p> \/\/if all answers are no, display link2 and hide link2; if any answers are yes, do the opposite.<\/p>\n<p> function showdiv() { if (x==1 | y==1 | z==1){ document.getElementById('link1').style.display='block'; document.getElementById('link2').style.display='none'; } else { console.log(&quot;None of the questions is 1&quot;); document.getElementById('link1').style.display='none'; document.getElementById('link2').style.display='block'; } return; }<\/p>\n<p>\/\/How to structure your HTML to code. Onlick assigns value to x,y,z variables<\/p>\n<p>&#x3C;input type=&#x22;radio&#x22; onclick=&#x22;a1(1)&#x22; name=&#x22;q1&#x22;&#x3E;Yes<br \/>\n&#x3C;input type=&#x22;radio&#x22; onclick=&#x22;a1(0)&#x22; name=&#x22;q1&#x22;&#x3E;No<\/p>\n<p>\/\/execute code<br \/>\n&#x3C;button onclick=&#x22;showdiv()&#x22;&#x3E;What Form Do I Need?&#x3C;\/button&#x3E;<\/p>\n<p>\/\/hide show divs using IDs<br \/>\n&#x3C;div id=&#x22;link1&#x22;&#x3E;<br \/>\nLink 1<br \/>\n&#x3C;\/div&#x3E;<br \/>\n&#x3C;div id=&#x22;link2&#x22;&#x3E;<br \/>\nLink 2<br \/>\n&#x3C;\/div&#x3E;<\/p>\n<p><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A short questionnaire to direct users to the right form using Javscript window.onload = function() { document.getElementById(&#8216;link1&#8217;).style.display = &#8216;none&#8217;; document.getElementById(&#8216;link2&#8217;).style.display = &#8216;none&#8217;; }; \/\/Clears div box var x, y, z; \/\/assigns variables to radio selections function a1(answer1){ x = answer1; }; function a2(answer2){ y = answer2; }; function a3(answer3){ z = answer3; }; \/\/if all &hellip; <a href=\"https:\/\/sls.gmu.edu\/web\/2018\/02\/21\/events-planning-form-using-javascript\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Events Planning Form Using Javascript&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[11],"tags":[18],"class_list":["post-802","post","type-post","status-publish","format-standard","hentry","category-web-development","tag-javascript"],"_links":{"self":[{"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/posts\/802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/comments?post=802"}],"version-history":[{"count":0,"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/posts\/802\/revisions"}],"wp:attachment":[{"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/media?parent=802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/categories?post=802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/tags?post=802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}