JavaScript - Hide/show Div - What's Wrong With My Code?
Could anyone tell me what I've doing wrong, on first click it detects that the div is hidden and makes it visible, button on second click it does nothing:
Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <link href="basic.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function hideshow(id) { if (document.getElementById(id).style.visibility = "hidden") { document.getElementById(id).style.visibility = "visible"; } else { document.getElementById(id).style.visibility = "hidden"; } } </script> </head> <body> <div id="test" onclick="hideshow('test2')"> </div> <div id="test2" style="visibility:hidden"> </div> </body> </html> Similar TutorialsHello all, I am creating a blog and I thought it would be cool to have the Konami code in it. Basically, I would like is to either show or hide a div when the code is entered. So lets say the Div is hidden, they would enter the code and it would then show. If it was entered while the div was shown, it would then hide. Is there any way to do this? I think there would be, but I don't know how to accomplish it. Here's a link to the Konami code I'm using: Code: if ( window.addEventListener ) { var state = 0, konami = [38,38,40,40,37,39,37,39,66,65]; window.addEventListener("keydown", function(e) { if ( e.keyCode == konami[state] ) state++; else state = 0; if ( state == 10 ) window.location = "http://example.com"; }, true); } Thank you! ok trying to get a Div tag to show if something is True and hide if something is False JS Code: unction eToggle(anctag,darg) { var ele = document.getElementById('Module1'); var ele = document.getElementById('Module2'); var ele = document.getElementById('Module3'); var ele = document.getElementById('Module4'); if("module1" + "module2" + "module3" + "module4" <40) { div.id.Failed = "block"; div.Failed = "Failed"; } else { div.style.Passed = "block"; div.Passed = "show"; } } HTML Code: <div id="Fail" class="hidden" style="display: none"><b><i>You will need to Repeat the Semester!</b> <br /> </div> <div id="Passed" class="hidden" style="display: none"> <img src="faces.png" width="50" height="50"><b><i> "Good Job you passed the Semster!"</b></div> this is what im trying to do: http://www.linkstraffic.net/programm...d/movebox.html using this code: http://www.linkstraffic.net/programm...nd/movediv.php heres my code. can someone fix it? html: [CODE] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Chris MacDonald - Javascript Assignment 2</title> <link href="styles/styles.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="java.js"></script> <div id="header"> <div id="logo"><img src="images/beat.png" /></div> </div> <ul id="nav"> <li><a href="#">Home</a></li> <li><a href="http://beatthreads.bigcartel.com/category/tees">Shirts</a></li> <li><a href="#">About Us</a></li> </ul> </head> <body> <div id="content"> <a href="#" onclick="interv=setInterval('ShowBox()',3);return false;">Upcoming Designs</a> <div id="coverlogin"> <div id="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus tristique cursus dui, a venenatis diam consectetur fermentum. Nulla facilisi. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent aliquam ornare nunc non semper. Morbi blandit lectus non elit ultricies ultricies. Fusce mattis purus et eros ultrices et facilisis nulla consequat. Vestibulum tellus libero, tempor vel tincidunt nec, consectetur non ante. Donec sed malesuada felis. Mauris lorem lorem, ornare a rutrum quis, rutrum in mauris. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. <br/> <p align="left"><a href="#" onClick="interv=setInterval('HideBox()',3);return false;">X</a></p> </div> </div> </div> <div id="footer"> <div id="footertext">Beat Threads - 2010</div> </div> </body> </html> [CODE] javascript: // JavaScript Document var hh=0; var interv; //we show the box by setting the visibility of the element and incrementing the height smoothly function ShowBox() { //Depending on the amount of text, set the maximum height here in pixels if(hh==40) { clearInterval(interv); return; } obj = document.getElementById("coverlogin"); obj.style.visibility = 'visible'; hh+=2; obj.style.height = hh + 'px'; } function HideBox() { obj = document.getElementById("coverlogin"); if(hh==2) { obj.style.visibility = 'hidden'; obj.style.height = '0.1em'; clearInterval(interv); return; } hh-=2; obj.style.height = hh + 'px'; } [CODE] Can someone fix this for me? Code: <html> <head> <script type="text/javascript" src="jquery-1.6.1.min.js"></script> <script type="text/javascript"> function showonlyone(thechosenone) { var noticecontent = document.getElementsByTagName("div"); for(var x=1; x < noticecontent.length; x++) { name = noticecontent[x].getAttribute("name"); if (name == 'noticecontent') { if (noticecontent[x].id == thechosenone) { noticecontent[x].style.display = 'block'; } else { noticecontent[x].style.display = 'none'; } } } } </script> </head> <body> <center> <div id="parentdiv"> <div id="expandall">OPEN/CLOSE ALL</div> <div id="noticeheading1" class="noticeheading" name="noticeheading"; onClick="showonlyone('noticecontent1');">Heading 1</div> <div id="noticecontent1" name="noticecontent" class="noticecontent">awertysergyetwhwgertrhztrxdtykpopmift6hwe5awfwedaserhdy4hatefeshdgtrgd</div> <div id="noticeheading2" class="noticeheading" name="noticeheading"; onClick="showonlyone('noticecontent2');">Heading 2</div> <div id="noticecontent2" name="noticecontent" class="noticecontent">fh56serhgzsrxdtrjhgzsrltkjuytinubvre6io4exjhgftxtrokzet6ttawruthrthwru</div> <div id="noticeheading3" class="noticeheading" name="noticeheading"; onClick="showonlyone('noticecontent3');">Heading 3</div> <div id="noticecontent3" name="noticecontent" class="noticecontent">fdfjesrtaw5u4wgy5gw45use4syzerhgtawerfatrastaghgryseerathw5uz4de5ser5s</div> </div> </center> </body> </html> can anyone help on "OPEN/CLOSE ALL" to show or hide all .noticecontent divs Hi guys, im new to forums and need some help with my website. I have embed a flash player known as: JW player into my website and put it into a div. Now my problem is I want javascript to hide the div containing the flash player for atleast a few seconds to display a loading image.gif. How would I set this up? Im not to familiar about using javascript so im not sure if its even possible. Anways thx for any help ore suggestions related to this subject. Hello, I have the folowing code but it seems to be broken between "SM Decision Support" and "Incident and Request Management". Does anyone know how I resolve ?. The idea is when somebody opens the page all the sections are hidden/uncollapsed and the user can collapse individually each section with a click or by hitting the expand/collapse all link. ------------ Have placed code in attachment as too long for this section Hello, I'm trying to have a div be hidden on loading the page but when you click a link it will show the div... here's code I have but it doesn't show when you click the link... <script type="text/javascript"> function show(){ document.getElementById(test).style.display="block"; } </script> <div id="test" style="display:none;"> <p>Some text</p> </div> <a href="#" onclick="show(); return false;">Show</a> Im pretty new to JS so Im sure this is not the best way to go about this but it'll do for now, any suggestions welcome I have a script to show and hide various divs based on a function & var. The problem im having is that when ANY of the variables ('hate', 'ok' and 'love') are passed all 3 different feedback forms ('FeedbackHate', 'FeedbackOk' and 'FeedbackLove') appear, not just the one I want. here is the JS: Code: function sitesurveyswitch(emotion) { var e = emotion; document.getElementById('site_survey_hate').style.backgroundPosition = '0px 0px'; document.getElementById('site_survey_ok').style.backgroundPosition = '0px 0px'; document.getElementById('site_survey_love').style.backgroundPosition = '0px 0px'; document.getElementById('FeedbackHate').style.display = 'none'; document.getElementById('FeedbackOk').style.display = 'none'; document.getElementById('FeedbackLove').style.display = 'none'; if (e == 'hate') document.getElementById('site_survey_hate').style.backgroundPosition = '-80px 0px'; document.getElementById('FeedbackHate').style.display = 'block'; if (e == 'ok') document.getElementById('site_survey_ok').style.backgroundPosition = '-80px 0px'; document.getElementById('FeedbackOk').style.display = 'block'; if (e == 'love') document.getElementById('site_survey_love').style.backgroundPosition = '-80px 0px'; document.getElementById('FeedbackLove').style.display = 'block'; } and here is the code related to this function: Code: <div id="siteSurveyBox"> <span id="site_survey_hate" onclick="sitesurveyswitch('hate');return false;"></span> <span id="site_survey_ok" onclick="sitesurveyswitch('ok');return false;"></span> <span id="site_survey_love" onclick="sitesurveyswitch('love');return false;"></span> </div> <div id="FeedbackHate" style="display:none; margin-top:-28px;"> FEEDBACK FORM IS HERE </div> <div id="FeedbackOk" style="display:none; margin-top:-28px;"> FEEDBACK FORM IS HERE </div> <div id="FeedbackLove" style="display:none; margin-top:-28px;"> FEEDBACK FORM IS HERE </div> Hi all, Check this code: PHP Code: <a>text</a> <div id="pkg">pkg</div> <div id="table_pkg">table_pkg</div> I'd like to show table_pkg and hide pkg when I click on <a>text</a>. How can I do? Thank you very much I don't know a lot about Javascript... still learning.. I am trying to create a show/hide effect that displays an image based on the users text input. I have coded this before for a list/menu and it works fine. With this particular project there are too many selections to choose from to put in a list/menu. I am trying to use if and else if statements to make this work. With the code the way it is only the first function on the list works. I tried just using repeating if statements and only the last function on the list works. Here is the code: Code: <script type="text/javascript" > function showSample() { if (document.getElementById('input').value='SW001') { document.getElementById('SW001').style.display='block'; document.getElementById('SW002').style.display='none'; document.getElementById('SW003').style.display='none'; document.getElementById('SW004').style.display='none'; } else if (document.getElementById('input').value='SW002') { document.getElementById('SW001').style.display='none'; document.getElementById('SW002').style.display='block'; document.getElementById('SW003').style.display='none'; document.getElementById('SW004').style.display='none'; } else if (document.getElementById('input').value='SW003') { document.getElementById('SW001').style.display='none'; document.getElementById('SW002').style.display='none'; document.getElementById('SW003').style.display='block'; document.getElementById('SW004').style.display='none'; } else if (document.getElementById('input').value='SW004') { document.getElementById('SW001').style.display='block'; document.getElementById('SW002').style.display='none'; document.getElementById('SW003').style.display='none'; document.getElementById('SW004').style.display='none'; } else if (document.getElementById('input').value='SW005') { document.getElementById('SW001').style.display='none'; document.getElementById('SW002').style.display='none'; document.getElementById('SW003').style.display='none'; document.getElementById('SW004').style.display='block'; } } </script> <style type="text/css"> <!-- #main { width: 400px; margin-right: auto; margin-left: auto; height: 125px; } #imageArea { float: right; width: 200px; } #formArea { float: left; width: 200px; height: 125px; } .image { height: 125px; width: 125px; margin-right: auto; margin-left: auto; display: none; } #SW001 { background: url(../_images/Colorfil/SW0001.jpg) no-repeat center center; } #SW002 { background: url(../_images/Colorfil/SW0002.jpg) no-repeat center center; } #SW003 { background: url(../_images/Colorfil/SW0003.jpg) no-repeat center center; } #SW004 { background: url(../_images/Colorfil/SW0004.jpg) no-repeat center center; } #SW005 { background: url(../_images/Colorfil/SW0005.jpg) no-repeat center center; } --> </style> </head> <body> <div id="main"> <div id="imageArea"> <div class="image" id="SW001"></div> <div class="image" id="SW002"></div> <div class="image" id="SW003"></div> <div class="image" id="SW004"></div> <div class="image" id="SW005"></div> </div> <div id="formArea"> <form action="" method="get"> <input type='text' name="input" id='input' /> <input name="" type="button" onclick="showSample(this.selectedIndex)"/> </form> </div> </div> </body> </html> Any help would be greatly appreciated! I know that this can be done using .hide/.show... I don't know how to say this but if you'll look at the code: Code: <div id="isclickable"> klasdlkasdklaklsjd <div id="weeeee"> trolololololol </div> </div> <div id="isclickable"> klasdlkasdklaklsjd <div id="weeeee"> trolololololol </div> </div> The div having an id of "weeeee" will show if id="isclickable" is clicked.. but not all divs having "weeeee" should show but instead what is inside the div "isclickable" is there a way to attain this without creating multiple scripts and ids? Thanks> hey i need help of all u guys.Actually the problem is that when i am loading this html page i just want the sign in page to appear and on click of cancel button i want a page to appear and on click of login button i get log in page..but the problem is that whenever i load my html page i get the sign in page and the page that is present on the cancel page..i tried showing and hiding and tried but i dnt know what more to do...please help me out.. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title> </title> <link rel="stylesheet" type="text/css" href="styling.css"/> <script type="text/javascript" src="jquery-1.7.1.js"></script> <script type="text/javascript"> window.onload = function() { document.getElementById('first_div').style.display = 'none';} function toggle(link, div1id, div2id) { var div1 = document.getElementById(div1id); var div2 = document.getElementById(div2id); if (div1.style.display == 'none') { $('#third_div').hide(); div1.style.display = 'block'; div2.style.display = 'none'; link.innerHTML = 'Login'; } else { $('#third_div').hide(); div1.style.display = 'none'; div2.style.display = 'block'; link.innerHTML = 'signin'; } } function toggleImg(divId) { $('#first_div').hide(); $('#second_div').hide(); $('#third_div').show(); } </script> </head> <body> <div id="first_div" class="container"> <label for="username"> <span>Username:*</span> <input type="text" class="text" id="user" placeholder="Username" maxlength="24" onFocus="this.style.borderColor='#B0E0E6';" onBlur="this.style.borderColor='#D3D3D3';"/> </label> <label for="password"> <span>Password:*</span> <input type="password" class="text" id="pass" placeholder="Password" maxlength="24" onFocus="this.style.borderColor='#B0E0E6';" onBlur="this.style.borderColor='#D3D3D3';"/> </label> <label> <input type="checkbox" name="remember" id="remember" class="checkbox" value="1" tabindex="3" /> Remember Me? </label> <label> <input type="submit" name="submit" class="button1" id="doLogin" value="Sign in" /> </label> </div> <div id="second_div" class="container1"> <label for="username"> <span> Username:*</span> <input type="text" id="username" class="text" placeholder="Username" maxlength="24" onFocus="this.style.borderColor='#B0E0E6';" onBlur="this.style.borderColor='#D3D3D3';"/> </label> <label for="password"> <span>Password:*</span> <input type="password" id="password" class="text" placeholder="Password" maxlength="24" onFocus="this.style.borderColor='#B0E0E6';" onBlur="this.style.borderColor='#D3D3D3';"/> </label> <label for="repass"> <span>Re-Password:* </span><input type="password" id="repass" class="text" placeholder="Re-password" maxlength="24" onFocus="this.style.borderColor='#B0E0E6';" onBlur="this.style.borderColor='#D3D3D3';"/> </label> <label for="email_id"> <span>Email-Id:</span><input type="text" id="email_id" class="text" placeholder="Verify email-id" maxlength="24" onFocus="this.style.borderColor='#B0E0E6';" onBlur="this.style.borderColor='#D3D3D3';"/> </label> <label><input type="submit" name="submit" class="button1" value="Submit" /></label> </div> <div id="third_div" class="image"> <img src="https://gs1.wac.edgecastcdn.net/8019B6/data.tumblr.com/tumblr_m2rdcqQLrA1qcb6kno1_500.jpg" /> </div> <div class="header"> <button class="button_cancel" onclick="toggleImg('third_div');">Cancel</button> <button class="button_sign" id="sign" onclick="toggle(this,'first_div', 'second_div'); return false;">Sign_in</button> </div> </body> </html> I wanted it according to this website https://www.tumblr.com Hi, onClick on a select element, I am trying to hide or show two different table rows. It does not seem to be working on internet explorer Thanks for any help! Code: function showMe (a, box) { document.getElementById(a).style.display = "table-row"; document.getElementById(a+"2").style.display = "table-row"; } function hideMe (a, box) { document.getElementById(a).style.display = "none"; document.getElementById(a+"2").style.display = "none"; } Code: <tr><td><b>Account Type:</b><br><small>(If you are both a club and college coach, please select college coach)</small>:</td><td><SELECT NAME="type" size="3"><OPTION VALUE="coach" onClick="hideMe('hide', this)" >Coach/Manager</OPTION><OPTION VALUE="college_coach" onClick="showMe('hide', this)">College Coach</OPTION> </SELECT></div> </td></tr> <tr id="hide" style="display:none;"><td><b>College:</b></td><td colspan="2"><input type="text" name="college" value=""></td></tr> <tr id="hide2" style="display:none;"><td><b>Title:</b></td> <td><select name="gender" size="1"> <option VALUE="men" >Men's</option><option VALUE="women" >Women's</option><option VALUE="both" >Men's and Women's</option> </select></div> </td> <td><select name="title" size="1"><OPTION VALUE="head" >Head Coach</OPTION><OPTION VALUE="assistant" >Assistant Coach</OPTION> </select></div> </td></tr> here is the live demo if you would like to see it: http://new.maddogmania.com/application/register.php I am trying to make it so when I mouseover on one div another div appears. And when I mouse out, the div disappears again. Here's what I have, it's not working. Both divs are always showing. Code: <script> function mover(){ document.getElementById("visiblediv").style.display="block" } function mout() { document.getElementById("visiblediv").style.display="none" } </script> <div id = "div1" onmouseover="mover()" onmouseout="mout()"> Show the div </div> <div id = "visiblediv" style="visibility:visible;border:1px dotted black"> This div is visible </div> Any way I can make this work any better? Am I supposed to have something in my main.css file? How can i make a function that a div container is hiding when i move with my mose over and it should be showed when i move with my mouse out. i tried it like that: <script type = text/javascript> function show() { document.getElementById("sidebar").style.visibility = "hidden"; } function hide() { document.getElementById("sidebar").style.visbility = "visible"; } </script> <div id ="sidebar"> <a href ="#" onmouseover = "show()"; onmouseout = "hide()"> </div> please tell me how i can solve this problem. and sorry for my english, i am from austria ;-) thanks Here is my code to show and hide two division via two links ... Nothing is happening......Can you plz suggest me, where I am wrong ? <html> <head> <script language="javascript" type="text/javascript"> function toggle(show, hide) { document.getElementByid(show).style.display = "block"; document.getElementByid(hide).style.display = "none"; } </script> </head> <body> <div> <a href="javascript:void()" onclick="toggle('first','second');" > First </a> <br/> <a href="javascript:void()" onclick="toggle('second','first');"> Second</a> <div id="first" style="display:none"> First division</div> <div id="second" style="display:none"> this is second division</div> </div> </body> </html> Got a quick question, I need to adjust the below code, so that when a question is open and you click on different question it automatically hides the question you opened first. How would I do that? Code: <!doctype html> <html> <head> <title>TEST TEMPLATE</title> <script type="text/javascript"> function showHide(id) { var div = document.getElementById(id); div.style.display = ( div.style.display == "none") ? "block" : "none"; } </script> </head> <body> <!------ QUESTIONS ------> <p>Change lines <li> to divs or whatever</p> <li onclick="showHide('FAQ1')">FAQ one</li> <li onclick="showHide('FAQ2')">FAQ two</li> <li onclick="showHide('FAQ3')">FAQ three</li> <!------ ANSWERS ------> <div id="FAQ1" style="display:none;"><p>Ans one</p></div> <div id="FAQ2" style="display:none;"><p>Ans two</p></div> <div id="FAQ3" style="display:none;"><p>Ans three etc etc.</p></div> </body> </html> Thanks, Jon I have a concatenated list of member names, with corresponding profile pics. I am trying to implement something similar to Facebook, where when you mouseover the picture or member name, another div appears, such as an "x" or "delete link" which lets you click to delete that member. I tried to implement the a show/hide with the following, but this won't work with me since my list is concatenated, and since you can only have one id per div- this method won't cut it. So, how can I make this happen? Non-working Code: Code: HTML <div > <div id="showhide"> Line 1 </div> <div id="visiblediv" style="display: none;"> Line 2 </div> </div> <div > <div id="showhide"> Line 3 </div> <div id="visiblediv" style="display: none;"> Line 4 </div> </div> <div > <div id="showhide"> Line 5 </div> <div id="visiblediv" style="display: none;"> Line 6 </div> </div> Javascript: <script> function mover(){ document.getElementById("visiblediv").style.display="block" } function mout() { document.getElementById("visiblediv").style.display="none" } document.getElementById('showhide').onmouseover=mover; document.getElementById('showhide').onmouseout=mout; </script> CSS: #visiblediv { visibility:visible; border:1px dotted black; } Good afternoon all, I need a bit fo help with unhiding a selection. I have a 10 checkboxes on a form. When the user clicks one of the boxes the rest are hidden and a comments box shows. That works great, the part I can't figure out is how to make all the boxes show again if the user unchecks the checkbox and make the comments box hide again. Here is the code I am using to do the hide: Code: function HideComments() { var a1 = document.getElementById("crmForm_answer1").checked; var a8 = document.getElementById("crmForm_answer8").checked; var a2 = document.getElementById("crmForm_answer2").checked; var a3 = document.getElementById("crmForm_answer3").checked; var a4 = document.getElementById("crmForm_answer4").checked; var a5 = document.getElementById("crmForm_answer5").checked; var a6 = document.getElementById("crmForm_answer6").checked; var a7 = document.getElementById("crmForm_answer7").checked; var a9 = document.getElementById("crmForm_answer9").checked; var a10 = document.getElementById("crmForm_answer10").checked; if(a1==true) { document.getElementById("crmForm_answer1_value").parentNode.parentNode.style.display = 'block'; document.getElementById("crmForm_answer8").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer2").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer3").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer4").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer5").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer6").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer7").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer9").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer10").parentNode.parentNode.style.display = 'none'; } else document.getElementById("crmForm_answer1_value").parentNode.parentNode.style.display = 'none'; if(a8==true) { document.getElementById("crmForm_answer8_value").parentNode.parentNode.style.display = 'block'; document.getElementById("crmForm_answer1").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer2").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer3").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer4").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer5").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer6").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer7").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer9").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer10").parentNode.parentNode.style.display = 'none'; } else document.getElementById("crmForm_answer8_value").parentNode.parentNode.style.display = 'none'; if(a2==true) { document.getElementById("crmForm_answer2_value").parentNode.parentNode.style.display = 'block'; document.getElementById("crmForm_answer1").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer8").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer3").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer4").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer5").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer6").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer7").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer9").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer10").parentNode.parentNode.style.display = 'none'; } else document.getElementById("crmForm_answer2_value").parentNode.parentNode.style.display = 'none'; if(a3==true) { document.getElementById("crmForm_answer3_value").parentNode.parentNode.style.display = 'block'; document.getElementById("crmForm_answer1").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer8").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer2").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer4").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer5").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer6").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer7").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer9").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer10").parentNode.parentNode.style.display = 'none'; } else document.getElementById("crmForm_answer3_value").parentNode.parentNode.style.display = 'none'; if(a4==true) { document.getElementById("crmForm_answer4_value").parentNode.parentNode.style.display = 'block'; document.getElementById("crmForm_answer1").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer8").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer2").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer3").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer5").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer6").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer7").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer9").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer10").parentNode.parentNode.style.display = 'none'; } else document.getElementById("crmForm_answer4_value").parentNode.parentNode.style.display = 'none'; if(a5==true) { document.getElementById("crmForm_answer5_value").parentNode.parentNode.style.display = 'block'; document.getElementById("crmForm_answer1").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer8").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer2").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer3").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer4").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer6").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer7").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer9").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer10").parentNode.parentNode.style.display = 'none'; } else document.getElementById("crmForm_answer5_value").parentNode.parentNode.style.display = 'none'; if(a6==true) { document.getElementById("crmForm_answer6_value").parentNode.parentNode.style.display = 'block'; document.getElementById("crmForm_answer1").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer8").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer2").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer3").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer4").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer5").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer7").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer9").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer10").parentNode.parentNode.style.display = 'none'; } else document.getElementById("crmForm_answer6_value").parentNode.parentNode.style.display = 'none'; if(a7==true) { document.getElementById("crmForm_answer7_value").parentNode.parentNode.style.display = 'block'; document.getElementById("crmForm_answer1").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer8").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer2").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer3").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer4").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer5").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer6").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer9").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer10").parentNode.parentNode.style.display = 'none'; } else document.getElementById("crmForm_answer7_value").parentNode.parentNode.style.display = 'none'; if(a9==true) { document.getElementById("crmForm_answer9_value").parentNode.parentNode.style.display = 'block'; document.getElementById("crmForm_answer1").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer8").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer2").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer3").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer4").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer5").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer6").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer7").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer10").parentNode.parentNode.style.display = 'none'; } else document.getElementById("crmForm_answer9_value").parentNode.parentNode.style.display = 'none'; if(a10==true) { document.getElementById("crmForm_answer10_value").parentNode.parentNode.style.display = 'block'; document.getElementById("crmForm_answer1").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer8").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer2").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer3").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer4").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer5").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer6").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer7").parentNode.parentNode.style.display = 'none'; document.getElementById("crmForm_answer9").parentNode.parentNode.style.display = 'none'; } else document.getElementById("crmForm_answer10_value").parentNode.parentNode.style.display = 'none'; } Thanks in advance for the help, Sam. Let me start by saying I'm a noob to JavaScript. What I'm trying to do for my website is have a select menu that shows the number of div's that's selected. I found a JS that I could do that with, but it only toggles, not change specifically what's selected. So if you click the wrong one, it doesn't work right. Here's what I got: Code: <body> <script type="text/javascript"> function toggle_visibility(){ for(var i = 0,len = arguments.length;i < len; i++){ var e = document.getElementById(arguments[i]).style,d = e.display; e.display = (d == "block") ? "none" : "block"; } } </script> <select name="select" id="select"> <option>0</option> <option onclick="toggle_visibility('1');" >1</option> <option onclick="toggle_visibility('1','2');">2</option> <option onclick="toggle_visibility('1','2','3');">3</option> <option onclick="toggle_visibility('1','2','3','4');">4</option> </select><br> <div id="1" style="display: none;">Test1</div> <div id="2" style="display: none;">Test2</div> <div id="3" style="display: none;">Test3</div> <div id="4" style="display: none;">Test4</div> </body> Any help would be appreciated, cause I'm lost. |