JavaScript - Show/hide Function Not Working In Firefox
Hi
I need help getting my show/hide function to work in all browsers. The function below works everywhere but Firefox. Can someone see why it's not working? My javascript function: Code: <script language="javascript" type="text/javascript"> function hideShow(el_id){ var el=document.getElementById(el_id); if(el_id.style.display!="none"){ el_id.style.display="none"; }else{ el_id.style.display=""; } } </script> My php code (sensured): PHP Code: $sql="*****"; $result= mssql_query($sql); echo "<table>"; echo "<tr><th>Header1</th><th>Header2</th><th>Header3</th><th>Header4</th></tr>"; $row=0; $row2=1; while($row = mssql_fetch_array($result)) { $id=$row["id"]; $row++; $row2++; echo "<tr>"; echo "<td>". $row['field1'] ."</td>"; echo "<td>". $row['field2'] ."</td>"; echo "<td><a onclick='hideShow(row$row);'> hide/show details</a></td>"; echo "</tr>"; echo "<tr id='row$row' style='display:none;'>"; echo "<td><b>Input1: </b>". $row['field3']."</td>"; echo "<td><b>Input2: </b>". $row['field4'] ."</td>"; echo "<td><b>Input3: </b>". $row['field5'] ."</td>"; echo "<td><a onclick='hideShow(row$row2)'>Delete this info</a></td>"; echo "</tr>"; echo "<tr id='row$row2' style='display:none;'>"; echo "<td>Are you sure you want to delete?</td>"; echo "<td><a onClick=menuRequest('$id')>Yes</a></td>"; echo "<td><a onClick=menuRequest('home')>No</a></td>"; echo "</tr>"; $row++; $row2++; } Similar TutorialsHello, For starters I'm a real javascript noob. The problem is I've got some code which which should display the contents of a div depending on which of two radio buttons are selected. Works fine in IE, but in Firefox, or even Safari it will display both divs if both are clicked. In other words it won't hide the div while it displays the other. The code is below, and any help would be appreciated. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> Help! </TITLE> <style type="text/css"> .hide {display: none} </style> <script type="text/javascript"> function hideDivArea(str_area_hide){ tag = document.getElementsByTagName("div"); for(x=0;x<tag.length; x++) { if(tag[x].getAttribute('id').indexOf(str_area_hide) != -1) { tag[x].style.display = "none"; } } } function showDivArea(areas_show, areas_hide){ for (var i = 0; i < areas_show.length; i++) { ge = document.getElementById(areas_show[i]); ge.style.display = "block"; } for (var i = 0; i < areas_hide.length; i++) { hideDivArea(areas_hide[i]); } } </script> </HEAD> <BODY> <form action="feedout.php" method="post"> <input type="hidden" name="action" value="sendmail" /> <table style="width: 435px" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td height="15" valign="bottom">Do you Own or Rent?:<span class="redtext">*</span></td> <td valign="bottom"> </td> </tr> <tr height="30"> <td colspan="2"> <div> <input type="radio" name="ownRent" value="own" size="34" onclick="javascript:showDivArea(['own'], ['rent'])">Own <input type="radio" name="ownRent" value="rent" size="34" onclick="javascript:showDivArea(['rent'], ['own'])">Rent <div class="hide" id="own"> Lawyer Name:<br /> <input type="text" name="lawyerName" size="34"><br /> Address:<br /> <input type="text" name="lawyerAddress" size="34"><br /> Telephone Number:<br /> <input type="text" name="lawyerPhone" size="34"><br /> </div> <div class="hide" id="rent"> Landlord Name:<br /> <input type="text" name="landlordName" size="34"><br /> Address:<br /> <input type="text" name="landlordAddress" size="34"><br /> Telephone Number:<br /> <input type="text" name="landlordPhone" size="34"><br /> </div> </div> </td> <tr> <td> <table width="240" border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="105" colspan="1" valign="middle" bordercolor="#000000" bgcolor="#ffffff"> <input style="border: solid 1px black;" type="submit" value="Submit Form"> </td> <td width="20" height="35"> </td> <td width="54" valign="middle"><input style="border: solid 1px black;" name="reset" type="reset" value="Clear Form"> </span></td> </tr> </tbody> </table> </td> <td> </td> </tr> </tbody> </table> </form> </BODY> </HTML> When I click the button, the images hide/show in IE, but this doesn't work in Firefox. I've tried JSLint and JavascriptLint, but haven't figured out what the issue is. Any help would be much appreciated!! This is the code below: <script language="Javascript"> <![CDATA[ function openConsole(docId, attachmentFileName, name) { if (window.customOpenConsole) { customOpenConsole(encodeURIComponent(attachmentFileName), name); } else { headerFrame = window.parent.parent.frames["Header"]; if (headerFrame != null && headerFrame.openDocLink != null){ headerFrame.openDocAttachment(docId, attachmentFileName, name); } } } function STGhide() { var x=document.getElementsByName("ImageControlZone"); for(j=0;j<x.length;j++) { var imgs = x[j].getElementsByTagName('img'); for(i=0;i<imgs.length;i++) { imgs[i].style.display="none"; } } var link = document.getElementById("ShowHideButton"); //alert(link.innerHTML) link.innerHTML ="<img alt='' src='img/hideshow/showimage.gif' border='0' onclick='javascript:STGshow();' />"; } function STGshow() { var x=document.getElementsByName("ImageControlZone"); for(j=0;j<x.length;j++) { var imgs = x[j].getElementsByTagName('img'); for(i=0;i<imgs.length;i++) { imgs[i].style.display=""; } } var link = document.getElementById("ShowHideButton"); link.innerHTML ="<img alt='' src='img/hideshow/hideimage.gif' border='0' onclick='javascript:STGhide();' />"; } function openDocumentLink(externalId, languageId) { if (window.parent.openDocLink != null) { window.parent.openDocLink(externalId, languageId); } else { headerFrame = window.parent.parent.frames["Header"]; if (headerFrame != null && headerFrame.openDocLink != null) { headerFrame.openDocLink(externalId, languageId); } else { setTimeout("openDocumentLink('"+externalId+"','"+languageId+"')",500); } } } ]]> </script> I have the CoffeeCup Website Font software that gives me a peek at the sIFR Javascript functions, but I can't figure out how to sIFR only the visible Div on my page. This script (from CoffeeCup) is in my page header: Quote: <script type="text/javascript"> //<![CDATA[ var h1_font = { src: 'websitefontdata/fonts/___1942_report[regular].swf' }; var h2_font = { src: 'websitefontdata/fonts/___gatecrasher[regular].swf' }; var h3_font = { src: 'websitefontdata/fonts/___High_Strung[regular].swf' }; var h4_font = { src: 'websitefontdata/fonts/___Palatino_Linotype[regular].swf' }; var h5_font = { src: 'websitefontdata/fonts/___Palatino_Linotype[regular].swf' }; var h6_font = { src: 'websitefontdata/fonts/___Beffle[regular].swf' }; sIFR.useStyleCheck = false; sIFR.fixHover = true; sIFR.fitExactly = true; sIFR.repaintOnResize = true; sIFR.preserveSingleWhitespace = false; sIFR.fromLocal = true; sIFR.activate(h1_font, h2_font, h3_font, h4_font, h5_font, h6_font); sIFR.replace(h1_font, {selector: 'h1', css: [ '.sIFR-root { line-height: 1em; font-size: 23px; color: #004080; background-color: #FFFFFF; text-align: left; font-weight: normal; font-style: normal; text-decoration: none; visibility: hidden; }', 'a { text-decoration: none; }', 'a:link { color: #004080; }', 'a:hover { color: #FF0000; }' ], filters: { DropShadow: { quality: 3, angle: 45, knockout: false, distance: 2.000000, color: '#000000', strength: 1.000000 } }, wmode: 'transparent' }); sIFR.replace(h2_font, {selector: 'h2', css: [ '.sIFR-root { line-height: 1em; font-size: 18px; color: #006C61; background-color: #FFFFFF; text-align: left; font-weight: normal; font-style: normal; text-decoration: none; visibility: hidden; }', 'a { text-decoration: none; }', 'a:link { color: #0000FF; }', 'a:hover { color: #FF0000; }' ], filters: { DropShadow: { quality: 3, angle: 45, knockout: false, distance: 4.000000, color: '#000000', strength: 1.000000 }, Glow: { quality: 2, strength: 2, blurX: 6.000000, blurY: 6.000000, knockout: 0, inner: 0, alpha: 0.250000, color: '#FFFF00' } }, wmode: 'transparent' }); sIFR.replace(h3_font, {selector: 'h3', css: [ '.sIFR-root { line-height: 1em; font-size: 23px; color: #000000; background-color: #FFFFFF; text-align: left; font-weight: normal; font-style: normal; text-decoration: none; visibility: hidden; }', 'a { text-decoration: none; }', 'a:link { color: #0000FF; }', 'a:hover { color: #FF0000; }' ], filters: { }, wmode: 'transparent' }); sIFR.replace(h4_font, {selector: 'h4', css: [ '.sIFR-root { line-height: 1em; font-size: 14px; color: #000000; background-color: #FFFFFF; text-align: left; font-weight: normal; font-style: normal; text-decoration: none; visibility: hidden; }', 'a { text-decoration: none; }', 'a:link { color: #000000; }', 'a:hover { color: #FF0000; }' ], filters: { }, wmode: 'transparent' }); sIFR.replace(h5_font, {selector: 'h5', css: [ '.sIFR-root { line-height: 1em; font-size: 14px; color: #000080; background-color: #FFFF80; text-align: left; font-weight: normal; font-style: normal; text-decoration: none; visibility: hidden; }', 'a { text-decoration: none; }', 'a:link { color: #0000FF; }', 'a:hover { color: #FF0000; }' ], filters: { }, wmode: 'transparent' }); sIFR.replace(h6_font, {selector: 'h6', css: [ '.sIFR-root { line-height: 1em; font-size: 20px; color: #004080; background-color: #FFFFFF; text-align: left; font-weight: normal; font-style: normal; text-decoration: none; visibility: hidden; }', 'a { text-decoration: none; }', 'a:link { color: #0000FF; }', 'a:hover { color: #FF0000; }' ], filters: { DropShadow: { quality: 3, angle: 45, knockout: false, distance: 2.000000, color: '#000000', strength: 1.000000 } }, wmode: 'transparent' }); //]]> </script> Here's what I'm working with to show a specific Div: Quote: function showSec(n) { hideSec(); if (ng5) document.getElementById('sec1').style.visibility = "visible"; else if (ns4) document.layers["sec1"].visibility = "show"; else if (ie4) document.all["sec1"].style.visibility = "visible"; if (ng5) document.getElementById('sec'+n).style.visibility = "visible"; else if (ns4) document.layers["sec"+n].visibility = "show"; else if (ie4) document.all["sec"+n].style.visibility = "visible"; } How do I have sIFR only draw the visible Divs? Hi, I am very new to javascript and html. I am trying to create a function which will hide or show a div (div1). Right now, it is always showing the div whether the boolean value is true or false. I know that it is getting inside the else if part, but it doesn't seem to be working. Code: <script type="text/javascript"> function hideDiv(flag) { if (flag == false) { document.getElementById('div1').style.visibility="visible"; } else if (flag == true) { document.getElementById(div1).style.visibility="hidden"; } } var bool = new Boolean(true) hideDiv(bool); </script> <body> <div id="div1"> Text! </div> </body> Thank you for taking a look Hi all! I have a function which shows and hides a div. It's working perfectly. But when i add another syntax such as FileSystemObject and AJAX with it, the show/hide function won't work anymore. Please help me to get it to work. Code: <script> function showhide() { document.getElementById("div").style.visibility = "visible" // Ajax Function Below // // End Ajax Function // } </script> In that code above the div wont show up. Please help me! Greetings, I recently learned that the <option> tags can not use the onclick attribute inside of IE. This works great for firefox, but sadly not a single version of internet explorer supports it (from what I am told via countless Google searches). I have been modifying my attempit at a solution to use the <select> tag with the attribute onchange. Maybe I am casing this wrong, or not seeing a solution as the below code does not operate in any browser, and no errors are reported back through firebug or IE. Excuse my sloopy attempt at {smarty tags} this script is written in a bunch of PHP object->vales and to save space cored the issue down to it's basics. On change of the select box, the value="5-28" is sent to javascript showBox to split the number away from the id_trips and only focus on the locations (the number before the '-' . IF the location matches the switch value then the box should show / hide or value change. The IDs are all correct I just think that there is a ' or a " or something off as I am not a javascript expert. my SQL return values <code class="php"> //PHP VARIABLES from QUERY sample loop 1 trip-number = 200 locations = 5 id_trips = 28 </code> my HTML form loop <code class="html"> {BEGIN LOOP 'trips'} <!--HTML form for {trip-number} --> <form id="trip{trip-number}" method="post" action="#"> <select id="depid{trip-number}" name="depId" class="inputed greybig required" onchange="showBox(this.value, '{trip-number}', 'dep');"> <option value="">Select Time</option> <option value="{locations}|{id_trip}">{trip-time}</option> </select> </form> <!--/HTML form for {trip-number} --> {/END LOOP 'trips'} </code> my javascript at the bottom of the page before the </body> <code class="javascript"> <!-- JAVASCRIPT AT END OF PAGE BEFORE CLOSING </body> I am using the jQuery Tools latest build 1.4.2 pull value, split and process for hide / show options --> <script type="text/javascript"> function showBox(val, trip, arrdep){ var splitVal = val.split("-"); switch (splitVal[0]){ case 1: //Airport $("#"+arrdep+"dep_win_airport"+trip).show(); case 2: //Port of Miami $("#"+arrdep+"_win_cruse"+trip).show(); case 4: //Port Canaveral $("#"+arrdep+"_win_cruse"+trip).show(); case 5: //door drop off $("#"+arrdep+"_win_door"+trip).show(); case 6: //Door Pick Up case 7://Airport NO FLIGHT default: $("#"+arrdep+"_window"+trip).hide(); $("#"+arrdep+"_info_"+trip).hide(); $("#"+arrdep+"_win_door"+trip).hide(); $("#"+arrdep+"_win_cruse"+trip).hide(); $("#"+arrdep+"_win_airport"+trip).hide(); $("#"+arrdep+"info_"+trip).val("Supply Address"); }; //end switch splitVal }; //end function showBox </script> </code> Hi to All, I have a table that contains many rows, some in italian with code <td nome='riga_i'> and some in english with code <td name='row_e'>. I have created two buttons with different background flags: italy and uk, so when one pushes the button with flag uk, the html page will be reloaded with only english rows, and when one pushes the button with flag it, the same page is reloaded containing only italian rows. All the code posted here works well, but I think that the code can be better because to reach this result I had to dupplicate the same function and I don' t like this. Here the code: <html> <head> <script type="text/javascript"> function toggle(name) { tr=document.getElementsByTagName('tr') for (i=0;i<tr.length;i++){ if (tr[i].getAttribute(name)){ if (tr[i].style.display=='none'){tr[i].style.display = '';} else {tr[i].style.display = 'none';} } } } // function toggle(nome) { tr=document.getElementsByTagName('tr') for (i=0;i<tr.length;i++){ if (tr[i].getAttribute(nome)){ if (tr[i].style.display=='none'){tr[i].style.display = '';} else {tr[i].style.display = 'none';} } } } </script> </head> <body onload="toggle('name');"> <table> <tr nome="riga_i"> <td>REQUISITI RELATVI AL SERVIZIO</td> <td> </td> <td><input type="button" onclick="toggle('nome');toggle('name');" style="background-image: url(../images/flag_uk.jpg); background-color:Transparent;" /></td></tr> <tr name="row_e"> <td> </td> <td>REQUIREMENTS RELATED TO THE SERVICE</td> <td><input type="button" onclick="toggle('name');toggle('nome');" style="background-image: url(../images/flag_italy.jpg); background-color:Transparent;" /></td></tr> .... .... and so on.... ..... </table></html> To better the code I have tried in this way but without success ... <html> <head> <script type="text/javascript"> function toggle(this) { if (this=='nome' || this=='name'){ tr=document.getElementsByTagName('tr') for (i=0;i<tr.length;i++){ if (tr[i].getAttribute(this)){ if (tr[i].style.display=='none'){tr[i].style.display = '';} else {tr[i].style.display = 'none';} } } } } </script> </head> Thanks in advance !!! i'm still a relative noob and this has me stuck - i have a save button with a "save as copy" in the save dropdown list. add new item directs to a premade/formatted project that is used as a template, so on that item i only want/need the "save as copy" but on all other items that use the form i need to only have the "save" function. is there any way to either change the function of the button depending on item that is being viewed in the edit screen OR hide the "save" button and only show the button associated with "save as copy - and vis versa for the rest of the items?? current button code is - protected function getToolbar() { $options = array(); $user = JFactory::getUser(); $create_ms = $user->authorise('core.create', 'com_pfmilestones'); $create_task = $user->authorise('core.create', 'com_pftasks'); $options[] = array( 'text' => 'JSAVE', 'task' => $this->getName() . '.save'); $options[] = array( 'text' => 'Save as new project', 'task' => $this->getName() . '.save2copy', 'options' => array('access' => ($this->item->id > 0))); PFToolbar::dropdownButton($options, array('icon' => 'icon-white icon-ok')); item used as template is id=8 any help or suggestions would be greatly appreciated.. Hey everyone. I have built a simple page for where I work, nothing complex going on here at all. But for some reason it won't run the Javascript functions in Firefox. Sarfari and Chrome work fine. It's not calling any external files or anything, like I said super simple. So if anyone can go to the page, view the source, take a look and let me know what I am missing here I would be greatly appreciative. http://www.aaronhager.com/BM/ To see what it does, just open that link in Chrome or Safari. I am more of a Flash guy then Javascript, and hopefully the reason is simple for one of you geniuses out there. Thanks A. 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! 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 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 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? 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'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> 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> 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 Hi there, I have a site which consists of the html page and css page. I have been trying to get the image at the top of the page to dissapear when the user clicks on the footer. Any suggestions on how I can do this? Below is my code, Thanks in advance. HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>JavaScript</title> <link href="css/main.css" rel="stylesheet" type="text/css" /> <style type="text/css"> body { background-color: #CC6; } </style></head> <body> <div id="header-wrap"> <div id="header-container"> <div id="header"> <h1>JavaScript</h1> </div> </div> </div> <div id="ie6-container-wrap"> <div id="container"> <DIV STYLE="font-size:12pt" onmouseover="this.style.fontSize='16pt'" onmouseout="this.style.fontSize='12pt'"> <div id="content"> <h1>Mainframe</h1> <p>Enter the content of your website within this area.</p> </div></DIV> </div> </div> <div id="footer-wrap"> <div id="footer-container"> <div id="footer"> <center> <body onLoad="dateandtime()"> <script> var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") var montharray=new Array("January","February","March","April","May","June","July","August","September","October","Novem ber","December") function getthedate(){ var mydate=new Date() var year=mydate.getYear() if (year < 1000) year+=1900 var day=mydate.getDay() var month=mydate.getMonth() var daym=mydate.getDate() if (daym<10) daym="0"+daym var hours=mydate.getHours() var minutes=mydate.getMinutes() var seconds=mydate.getSeconds() var dn="AM" if (hours>=12) dn="PM" if (hours>12){ hours=hours-12 } if (hours==0) hours=12 if (minutes<=9) minutes="0"+minutes if (seconds<=9) seconds="0"+seconds var cdate="<small><font color='#87ac6d' font size='2.5' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn +"</b></font></small>" if (document.all) document.all.clock.innerHTML=cdate else document.write(cdate) } if (!document.all) getthedate() function dateandtime(){ if (document.all) setInterval("getthedate()",1000) } </script> <span id="clock"></span> </center> </div> </div> </div> </body> </html> CSS: body { font: 62.5% Arial, Helvetica, sans-serif; color: #597347; margin: 0; padding: 0; background: #beffbf; } h1, h2 { color: #87ac6d; font-family: Tahoma, Arial, Geneva, sans-serif; margin: 20px 0 10px; } h1 { font-size: 2.5em; } p { margin: 10px 0; padding: 0; } blockquote { font-style: italic; } #header-wrap { position: fixed; top: 0; left: 0; width: 100%; } #header-container { height: 90px; background: url(../images/banner.jpg) repeat-x left bottom; } #header { width: 940px; margin: 0 auto; position: relative; } #header h1 { color: #beffbf; text-align: right; width: 290px; margin: 0; position: absolute; left: 476px; top: 32px; } #header h1 em{ color: #90b874; font-size: small; display: block; } #header ul { margin: 0; padding: 0; list-style: none; position: absolute; top: 35px; right: 0; } #header ul li { float: left; margin-right: 5px; } #header ul li a{ color: #90b874; font-weight: bold; font-size: 1.4em; margin-right: 5px; text-decoration: none; } #header ul li a:hover { color: #beffbf; } #container { width: 940px; margin: 0 auto; font-size: 1.4em; overflow: auto; padding: 90px 0 40px; } #content { float: left; width: 100%; } #sidebar { float: right; width: 275px; margin-top: 10px; } #footer-wrap { position: fixed; bottom: 0; left: 0; width: 100%; } #footer-container { height: 40px; background-color: #000; } #footer { width: 940px; margin: 0 auto; position: relative; } Alright, me having a very basic knowledge of js I'm looking for some help with(what I think should be) a simple hide/show of a set of divs. I've broken down the ccs/html I'm looking at on a test page here - http://www.grinnbarrett.net/test.html The js I have in the page had been what I tried to modify from a simple hide/show, but it's not doing what I want it to do (obviously). The goal is when you click on link 3, I want white3 to hide and all the other white divs to show, when you click on link 3, white 2 will hide and the other white divs will show, and so on. So basically it's revealing what div you click to. A lot of what I've found have been just toggles, but I'm not very confident in my ability to adjust code. Any and all help would be appreciated. |