JavaScript - Close Button On Popup Not Working In Ie?
I'm implementing that stupid Cookie Law thing here in the UK, but I can't get the popup to close on click in IE. Every other browser is working fine. Any one know the fix?
Code: <style type="text/css"> <!-- #eucookielaw { display:none } #note { position: fixed; z-index: 101; bottom: 0; left: 0; right: 0; background: #98FB98; text-align: center; vertical-align: middle; color: #2C2C2C; line-height: 2.5; overflow: hidden; -webkit-box-shadow: 0 0 5px black; -moz-box-shadow: 0 0 5px black; box-shadow: 0 0 5px black; } #note a { color: #2C2C2C; } #note img { vertical-align: middle; } #close { cursor: pointer; } @-webkit-keyframes slideDown { 0%, 100% { -webkit-transform: translateY(-50px); } 10%, 90% { -webkit-transform: translateY(0px); } } @-moz-keyframes slideDown { 0%, 100% { -moz-transform: translateY(-50px); } 10%, 90% { -moz-transform: translateY(0px); } } .cssanimations.csstransforms #note { -webkit-transform: translateY(-50px); -webkit-animation: slideDown 2.5s 1.0s 1 ease forwards; -moz-transform: translateY(-50px); -moz-animation: slideDown 2.5s 1.0s 1 ease forwards; } .cssanimations.csstransforms #close { display: none; } --> </style> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> function SetCookie(c_name,value,expiredays) { var exdate=new Date() exdate.setDate(exdate.getDate()+expiredays) document.cookie=c_name+ "=" +escape(value)+";path=/"+((expiredays==null) ? "" : ";expires="+exdate.toUTCString()) } </script> <div id="eucookielaw" > <div id="note"> <img src="/images/cookie_sm.png" alt="Cookie" border="0"> This Site Uses Cookies. :: <a rel="nofollow" href="/terms.php">Learn More</a> :: <a id="close"><u>Close this Message</u> <img src="/images/close_sm.png" alt="Close" border="0"></a> </div> <script> close = document.getElementById("close"); close.addEventListener('click', function() { note = document.getElementById("note"); note.style.display = 'none'; }, false); </script> </div> <script type="text/javascript"> $("#eucookielaw").show(); SetCookie('eucookie','eucookie',365*10) </script> Example he No Claims Discount Insurance | Car, Home, Bike and Health No Claims Bonuses Similar TutorialsUnable to close the popup. Have done the best I can Can someone please help me here. Would also like to be able to display without scrolling bars Here is the link http://www.videowebmastery.com/video...ters/index.htm Cheers How to center javascript popup without css? Cant get close button working(wrong position and dosen't close popup). Code: <script language="javascript"> function openPopup(a, b, c){//a = url, b = width, c = height var pOverlay, pContent, pClose; pOverlay = document.createElement('div'); pOverlay.className = 'popupOverlay'; pContent = document.createElement('div'); pContent.className = 'popupContent'; pClose = document.createElement('div'); pClose.className = 'popupClose'; document.body.appendChild(pOverlay); document.body.appendChild(pContent); var myRequest = new ajaxRequest(); myRequest.open('GET', a, true); myRequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); myRequest.send(null); myRequest.onreadystatechange = function(){ if(myRequest.readyState == 4 && myRequest.status == 200){ pContent.innerHTML = myRequest.responseText; } } } </script> Code: <style type="text/css"> .popupOverlay { background: #000000; opacity: 0.8; position: fixed; top: 0%; left: 0%; width: 100%; height: 100%; z-index: 1001; } .popupContent { background: #333333; border: 2px solid #DDDDDD; box-shadow: 0px 0px 20px #999999; border-radius: 3px; position: absolute; top: 50%; left: 50%; padding: 5px; z-index: 1002; overflow: auto; word-wrap: break-word; color: #FFFFFF; /*height: 300px; width: 500px;*/ } .popupClose { background: url('images/closePopup.png') no-repeat; width: 32px; height: 32px; cursor: pointer; } </style> Hi , Kindly help I have to handle the browser RED X close button in the window. The problem is that its not saving the data. before submitting/saving the data it executes the window.close() I put settime out and form on submit conditionalyy put even its not saving the data But window is closing. how can we sequentiate the save + window.close() im copying the code below. ============ window.onbeforeunload = function() { if (window.event.clientY < 0 && (window.event.clientX > (document.documentElement.clientWidth - 5) || window.event.clientX < 15)) { editedCheck(); document.BuildRequestForm.buttonClicked.value="REDX"; if( document.BuildRequestForm.measdatachanged.value=="false") { setVarZero(); fn_Close(); } else { if(confirm('Do you want to save the changes?')) { elmtForm.onsubmit = fn_Close; //document.BuildRequestForm.onsubmit=fn_Close; //setVarZero() saveMeasurement(); setTimeout('setVarZero()',1000); //window.setTimeout(function() { window.close();}, 1000); //window.setTimeout(function() { fn_Close();}, 1000); //fn_Close(); //return true; } else { return "If you want to close the window click - Leave Page";} } } } ============= browser close RED X button+ popup OK Cancel "save or not" +OK I am having a heck of a time closing this popup window when i logoff the site. i open it by Code: shoutwindow = window.open("<?=$MY_LINK_ROOT?>/shoutbox/minichat.php", "shoutwindow", "location=0,status=0,scrollbars=0,menubar=0,resizable=0 width=300,height=310"); when i click logoff the site i want the popup to close also here is the logoff php Code: session_start(); //only for testing will remove this if(!shoutwindow.closed) { echo "window open"; self.close(); //shoutwindow.close (); // also tried both these didnt work // window.close(); } else { echo "Window already closed"; } mysql_close($link); unset($_SESSION['Sess_UserId']); // Unset all of the session variables. session_unset(); // Finally, destroy the session. session_destroy(); echo "<script> location.href='$MY_LINK_ROOT'</script>"; exit; ?> what am i missing here lol ? thanks UPDATE: i just had an idea, can i mix a href and an onClick together so that both are executed like this (i never tried it before) Code: the reason i use self.close is because i heard that it always closes the child not the parent. <a href="logoff.php" onClick="self.close()" return:true;>Log Off</a> the return true will make it execute the href as well right? Trying to get this link to close window onclick, can I even do it? I'm just not seeing how, but I'm probably missing the obvious... Code: <img usemap="#map3" id="shapeimage_5" src="Notice2_files/shapeimage_5.png" style="border: none; height: 49px; left: -67px; position: absolute; top: -3px; width: 261px; z-index: 1; " alt="December 2011 notice" title="" /><map name="map3" id="map3"><area href="https://docs.google.com/open?id=0BwxS6NVXBkCvMTZiMTc1MzYtNDA1Yi00YzRjLWFjNDktNGI5ZDVjYTJkNTkw" title="https://docs.google.com/open?id=0BwxS6NVXBkCvMTZiMTc1MzYtNDA1Yi00YzRjLWFjNDktNGI5ZDVjYTJkNTkw" alt="https://docs.google.com/open?id=0BwxS6NVXBkCvMTZiMTc1MzYtNDA1Yi00YzRjLWFjNDktNGI5ZDVjYTJkNTkw" coords="67, 3, 258, 46" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;" /></map> Hey guys, Been searching on google for two days now, without a valid answer. I'm NEW to javascript, so I need some good help on this haha. I am using the following little piece of code to open a popup window: Code: <SCRIPT LANGUAGE='JAVASCRIPT' TYPE='TEXT/JAVASCRIPT'> <!-- var win=null; function NewWindow(mypage,myname,w,h,pos,infocus){ if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;} if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;} else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20} settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings); win.focus();} // --> </script> The actual link to open the popup is like this: Code: <a href="javascript:NewWindow('upload.php','popup','550','252','center','front');">Open the popup</a> What I am opening is, an upload page to upload an image (PHP / AJAX). Once the upload is complete and I close the window, I need the parent window (the index page which the link to open the popup is on) to be refreshed, so you can see that the file has been successfully uploaded. Does anyone have a clue how I would fix this? If I need to use another code to open the popup, that's fine, I just need help on how to fix this, since I haven't been able to find the answer myself. Thanks in advance! Hello, I am trying to work on the following: You open the cart page and click the pay now button, that button opens a new window. I am trying to write (and I bet this is easy but I can't seem to get it) a script so that when it detects that window closing to automatically forward the main page to an account page. Is it something like: Code: <script type="text/javascript"> header(Location:"http://www.mysite.com"); if (window.opener.progressWindow) { window.opener.progressWindow.close() } window.close(); } </script> I am no programmer I have a popup window that has a "link" inside it, which needs to have a target=_blank but when ever clicked in IE, it stays inside the same window. I tried all of the following, none work PHP Code: <a href='http://www.myurl.net' onclick='window.close();' target='_blank'> <a href="http://www.myurl.net" target="_blank" onClick="javascript:window.close()"> <a href="http://www.myurl.net" target="_blank" onClick="javascript: setTimeout(window.close, 10);"> Thanks Sonny Hi! I'm new to this, so please bare with me. My terminology may not be up to par. Here's the deal: - I have a button on my Flash site that opens an HTML page in a popup window. In Flash, I open the new window using Actiosnscript 2.0: Code: on (release) { getURL("example1.html", "_blank"); } - Within the popup window are links to other HTML pages. They all open in the same window. I've been using the following to create the links in Dreamweaver: Code: onClick="MM_goToURL('parent','example2.html')" - On each page, I have a "Return to Main Menu" button that should close the popup window. To do this, I have been using: Code: onClick="window.close()" - The problem is that it works differently in each browser, and I can't even get it to consistently close the window in most browsers: Internet Explorer = popup message appears, asking "Are you sure you want to close this window?" or something similar; window closes after clicking "Yes." Safari = Only closes if I'm on the original HTML page. If I click on any of the other links (note that these all open in the same window), those pages' "Return to Main Menu" buttons cease to work. However, if I keep clicking "Back" until I get to the original page, it closes. Opera = Button actually works for each page. Firefox & Chrome = Does not close the window at all. I looked into it and saw that others have used a window.opener to solve similar issues. But, since my popup window is opened using Flash/AS2, I need to find a way around it. I've tried preceding "window.close()" with "window.opener=null" (i.e. - onClick="window.opener=null; window.close()"), but I don't think I'm doing it right because it still doesn't work. I've also seen others use codes that involve functions and variables, but it is beyond my current coding knowledge to implement this. Like I said, I'm sort of new at this. Any advice would be greatly appreciated. Thank you. - PW Have been trying to make a button to close a web page but every time i try to get it validated "strict" it fails. I have used the following code. Code: <form action=""> <input type="button" value="Close Window" onclick="window.close()"> </form> Would really appreciate any help. Thanks Does anyone knows how to make an overlay ad with close button? Well I have seen already on another websites.I want to make an ad which is over a video and that video can't be started without closing this ad.So when ad is closed then video can be loaded.Something like on this webiste: http://www.soccerclips.net/videos/we...-villa-fortune But i don't know how to do it?If someone knows please post the code. Hi, I have the following problem: When I use this script it pops up both if a user tries to close the window and also if he presses the back button. Please tell how to show another window or do another action when the back button is pressed? I know it is possible although a lot of people say it's not. Code: <script type="text/javascript" type="text/javascript"> window.onbeforeunload = confirmExit; function confirmExit() { return "blabla"; } </script> i used the code window.close(); it works well for Internet Explorer but it not worked in firefox Hi guys, I have read that the window.close won't work unless the window was opened through window.open. Eventhough I have the window opening through window.open method the window.close simply wont close the window. Below is my code. I appreciate you help as I am desperate to finish my project and this is the only thing between me and the closed project. I have this in the <head> in the parent window. Code: <script language="javascript"> function MM_openBrWindow(theURL,winName,features){ var left = (screen.width/2)-(800/2); var top = (screen.height/2)-(560/2); features = features + ",left=" + left; window.open(theURL,winName,features); } </script> the left and top is to center the window which is working. Then I have the below code in my button which is to open the window. Code: <input type="button" value="E-MAIL" onClick="MM_openBrWindow('email.php?camp_id=<?php echo $encrypted; ?>','','width=860,height=600'); return false"/> The $encrypted is created beforehand and the window gets opened as well. Now in the popup window... Up on submitting a form, I need the popup to close after saying 'email has been sent'. this is the code for calling the fuction Code: echo "<script language='javascript'>success();</script>"; I get the alert too. Code: function success(){ alert('E-Mail Sent Successfully'); window.close(); } I even get the alert mentioning "E-Mail Sent Successfully". But simply the window is not closed. Can you guys please shed me some light on this.... Your help is greatly appreciated Ohh and by the way I'm running FF8. Cheers E My code works but when I put an image in there my code doesn't work anymore. Quote: <html> <head> <style type="text/css"> .planType{display:none; width:600px} </style> <script type="text/javascript"> <!-- function planTypeOpen(planID) { document.getElementById('info_' + planID).style.display = "block"; document.getElementById('title_' + planID).innerHTML="<a href=\"javascriptlanTypeClose('" + planID + "');\">Check this out" + "</a>"; } function planTypeClose(planID) { document.getElementById('info_' + planID).style.display = "none"; document.getElementById('title_' + planID).innerHTML="<a href=\"javascriptlanTypeOpen('" + planID + "');\">Check this out" + "</a>"; } //--> </script> </head> <body> <div id="title_1"><a href="javascriptlanTypeOpen('1');">Check this out</a></div> <div id="info_1" class="planType"> You can't see me...<br> Or Can you?? </div> </body> </html> any comments would be greatly appreciated. below code is not working for IE7. function closeWindowFun(e){ winX = navigator.appName=="Microsoft Internet Explorer" ? window.event.clientX : event.screenX; winY =navigator.appName=="Microsoft Internet Explorer" ? window.event.clientY :event.screenY; temp=navigator.appVersion.split("MSIE"); version=parseFloat(temp[1]); alert(version); closeFlg=false; if(version>=7){ if ((window.event.clientY < 0 && (window.event.clientY >-20 || window.event.clientY <-100)) && (window.event.clientX > (document.documentElement.clientWidth - 5) || window.event.clientX < 15) ){ loseFlg=true; } } else{ if(winX<0 && winY<0){ closeFlg=true; } } if(closeFlg){ window.opener.location .reload(); window.close(); } } please give me suggestions Hello everyone. I am trying to add the functionality of having a mouseover popup image with multiple different popup images. I have found the code seen below and altered it for my uses and was hoping to find out if someone can tell me why I am seeing the same image with each mouseover. Thanks. <script type="text/javascript"> function ShowPopup(hoveritem) { hp = document.getElementById("hoverpopup"); // Set position of hover-over popup hp.style.top = hoveritem.offsetTop + 18; hp.style.left = hoveritem.offsetLeft + 20; // Set popup to visible hp.style.visibility = "Visible"; } function HidePopup() { hp = document.getElementById("hoverpopup"); hp.style.visibility = "Hidden"; } </script> <table> <tbody> <tr> <td><a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"><img width="20" height="20" alt="" src="http://entrixsports.com//ir/oi/1000954/1867796.jpg" /></a> <a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"> </a> <div id="hoverpopup" style="visibility: hidden; position: absolute; top: 245pt; left: 290pt;"><img width="214" height="300" alt="" src="http://entrixsports.com//ir/oi/1000954/1851557.jpg" /></div> </td> <td><a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"><img width="20" height="20" alt="" src="http://entrixsports.com//ir/oi/1000954/1867803.jpg" /></a> <a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"> </a> <div id="hoverpopup" style="visibility: hidden; position: absolute; top: 245pt; left: 290pt;"><img width="214" height="300" alt="" src="http://entrixsports.com//ir/oi/1000954/1851637.jpg" /></div> </td> <td><a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"><img width="20" height="20" alt="" src="http://entrixsports.com//ir/oi/1000954/1867802.jpg" /></a> <a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"> </a> <div id="hoverpopup" style="visibility: hidden; position: absolute; top: 245pt; left: 290pt;"><img width="214" height="300" alt="" src="http://entrixsports.com//ir/oi/1000954/1851627.jpg" /></div> </td> <td><a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"><img width="20" height="20" alt="" src="http://entrixsports.com//ir/oi/1000954/1867799.jpg" /></a> <a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"> </a> <div id="hoverpopup" style="visibility: hidden; position: absolute; top: 245pt; left: 290pt;"><img width="214" height="300" alt="" src="http://entrixsports.com//ir/oi/1000954/1851597.jpg" /></div> </td> <td><a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"><img width="20" height="20" alt="" src="http://entrixsports.com//ir/oi/1000954/1867797.jpg" /></a> <a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"> </a> <div id="hoverpopup" style="visibility: hidden; position: absolute; top: 245pt; left: 290pt;"><img width="214" height="300" alt="" src="http://entrixsports.com//ir/oi/1000954/1851567.jpg" /></div> </td> <td><a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"><img width="20" height="20" alt="" src="http://entrixsports.com//ir/oi/1000954/1867798.jpg" /></a> <a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"> </a> <div id="hoverpopup" style="visibility: hidden; position: absolute; top: 245pt; left: 290pt;"><img width="214" height="300" alt="" src="http://entrixsports.com//ir/oi/1000954/1851577.jpg" /></div> </td> <td><a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"><img width="20" height="20" alt="" src="http://entrixsports.com//ir/oi/1000954/1867800.jpg" /></a> <a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"> </a> <div id="hoverpopup" style="visibility: hidden; position: absolute; top: 245pt; left: 290pt;"><img width="214" height="300" alt="" src="http://entrixsports.com//ir/oi/1000954/1851607.jpg" /></div> </td> <td><a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"><img width="20" height="20" alt="" src="http://entrixsports.com//ir/oi/1000954/1867801.jpg" /></a> <a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"> </a> <div id="hoverpopup" style="visibility: hidden; position: absolute; top: 245pt; left: 290pt;"><img width="214" height="300" alt="" src="http://entrixsports.com//ir/oi/1000954/1851617.jpg" /></div> </td> <td><a id="hoverover" style="cursor: default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();"><img width="20" height="20" alt="" src="http://entrixsports.com//ir/oi/1000954/1867804.jpg" /></a></td> </tr> </tbody> </table> <table width="270" cellspacing="1" cellpadding="1" border="0"> <tbody> <tr> <td><a href="javascriptopImage('http://entrixsports.com//ir/oi/1000954/1856598.jpg');"><img width="96" height="100" border="0" align="middle" alt="" src="http://entrixsports.com//ir/oi/1000954/1856097.jpg" /></a></td> <td style="text-align: center;"><a href="javascriptopImage('http://entrixsports.com//ir/oi/1000954/1856227.jpg');"><img width="65" height="100" border="0" align="middle" src="http://entrixsports.com//ir/oi/1000954/1856098.jpg" alt="" /></a></td> <td style="text-align: right;"><a href="http://entrixsports.com/linkTo/1304219/1000954" rel="nofollow" target="_blank"><img width="60" height="102" border="0" align="middle" alt="" src="http://entrixsports.com//ir/oi/1000954/1856099.JPG" /></a></td> </tr> </tbody> </table> I am using JavaScript for popups in my OpenLayers map. All the html tags like <br> work in the popup window except for the link href tag. Everytime I put in a link in my popup window it doesnt work: Code: var mystring = "here is link:<br> <a href=\"www.sun.com\">link</a>"; popup = New OpenLayers.Popup.FramedCloud("chck", feature.coord, null, mystring, null, true, onPopupClose); Also tried link without quotes and with ticks and nothing seems to work with the link not taking me anywhere. Please advise. Dear friends, I am using a Javascript which perfectly worked in all relevant browsers, including IE6 and IE7. Its advantage has been to be able to specify the window-size + to decide, whether there should be scrollbars or the option to resize it. It is also fully standards-compliant. It opens a new popup window and is triggered via the rel="popup" or rel="popup nofollow" attributes in the specified external links, e.g.: Code: <a href="http://www.codingforums.com/" rel="popup">CodingForums</a> <a href="http://www.codingforums.com/" rel="popup nofollow">CodingForums</a> The code however does not do its job in IE8. It follows the link, but does so in the old window, not a new popup window, and thus recurs to standard behavior of links. Here is the Javascript-Code, included in the header: Code: var properties = { width: 900, height: 450, scrollbars: 'yes', resizable: 'yes' }; function popup(){ var link = this.getAttribute( 'href' ); var prop_str = ''; for( prop in properties ){ prop_str = prop_str + prop + '=' + properties[prop] + ','; } prop_str = prop_str.substr( 0, prop_str.length - 1 ); var newWindow = window.open( link, '_blank', prop_str ); if( newWindow ){ if( newWindow.focus ) newWindow.focus(); return false; } return true; } function setupPopups(){ var links = document.getElementsByTagName( 'a' ); for( var i=0; i<links.length; i++ ){ if( links[i].getAttribute( 'rel' ) && (links[i].getAttribute( 'rel' ) == 'popup' || links[i].getAttribute( 'rel' ) == 'popup nofollow')) links[i].onclick = popup; } } window.onload = function(){ setupPopups(); } Since I am not an expert, I would greatly appreciate help to make this efficent code workable in IE8. Thanks in advance! CodeMat I've never had this problem in the past and I am now stumped. I've written a fairly long script to calculate numbers for a web based Diabetes calculator but for some reason the "Calculate" button does nothing when using Chrome, Opera or Safari for iOS. It does work when using IE, Firefox and Safari for PC. I've looked everywhere and found nothing but some references to an 'onclick' problem in Chrome. My problem is that the same method has always worked in the past and is still working in those scripts now so that can't be the issue. What is different about THIS button that is breaking it? Button WORKS here (IE, Chrome, Firefox, Safari-PC & iOS & Opera): http://jdrinc.webatu.com/FICC.html But DOES NOT work here (Chrome, Safari-iOS & Opera): http://jdrinc.webatu.com/D-Calc.html The second link DOES work in IE, Firefox & Safari-PC. I don't see a difference in the method that I'm using in either of these. Does anyone know what I am doing wrong? Here is the html with the script that is NOT working: Code: <html> <head> <title> D-Calc </title> <style type="text/css"> table { border:2px solid black; border-collapse:collapse; } th { border:2px solid black; border-collapse:collapse; font-family: Arial, Helvetica, sans-serif; text-align: left; font-weight: bold; } td { border:2px solid black; border-collapse:collapse; font-family: Arial, Helvetica, sans-serif; text-align: left; font-weight: bold; } .inputlabel { background-color: #6CC417; } .outputlabel { background-color: #6698FF; } .inputbox { border:0px inset blue; background-color: #FFFFFF; border-color: #FFFFFF; text-align: center; font-weight: bold; width: 100px; } .outputbox { border:0px inset blue; background-color: #FFFFFF; border-color: #FFFFFF; text-align: center; font-weight: bold; width: 100px; } </style> <script type="text/javascript"> function Calculate() { //input variables var B01, B02, B03, B04, B05, B06, B07, B08, B09, B10, B11 //output variables var B12, B13, B14, B15, B16, B17, B18, B19, B20, B21, B22, B23, B24, B25, B26 //correction sensitivity variable var CSV //new blood glucose var NBG //bloodsugar-carbohydrate ratio var BCR B01=eval(document.DCalcForm.B01.value); B02=eval(document.DCalcForm.B02.value); BCR=(B02/B01); B03=eval(document.DCalcForm.B03.value); B04=eval(document.DCalcForm.B04.value); B05=eval(document.DCalcForm.B05.value); B06=eval(document.DCalcForm.B06.value); B07=eval(document.DCalcForm.B07.value); B08=eval(document.DCalcForm.B08.value); B09=eval(document.DCalcForm.B09.value); B10=eval(document.DCalcForm.B10.value); B11=eval(document.DCalcForm.B11.value); B12=(B10*(B03/100)); B13=(B11*(B04/100)); B14=(B09+B12+B13); B15=(B09); B16=(B12+B13); if (B07<(B05+(B06+1)) && B07>(B05-(B06+1))) { CSV=(0); } else if (B07>(B05+B06)) { CSV=(B06); } else if (B07<(B05-B06)) { CSV=(-1*B06); } if (CSV==0) { B17=0; } else { B17=((B07-(B05+CSV))/B02); } B18=((B12*(B03/100))/B01); B19=((B13*(B04/100))/B01); B20=(B09/B01); if (CSV=0) { B21=((B18+B19+B20)-B08); } else { B21=((B17+B18+B19+B20)-B08); } B22=((B17+B20)-B08); B23=(B18+B19); if (B21==0) { B24=0; } else { B24=((B22/B21)*100); } if (B21==0) { B25=0; } else { B25=((B23/B21)*100); } NBG=(B07+((B09+B12+B13)*BCR)); if (B07<(B05+(B06+1)) && B07>(B05-(B06+1))) { CSV=(0); } else if (B07>(B05+B06)) { CSV=(B06); } else if (B07<(B05-B06)) { CSV=(-1*B06); } if (CSV==0) { B26=0; } else { B26=(((B05+CSV)-NBG)/BCR); } document.DCalcForm.B12.value=(Math.round(B12*100))/100 + ' g'; document.DCalcForm.B13.value=(Math.round(B13*100))/100 + ' g'; document.DCalcForm.B14.value=(Math.round(B14*100))/100 + ' g'; document.DCalcForm.B15.value=(Math.round(B15*100))/100 + ' g'; document.DCalcForm.B16.value=(Math.round(B16*100))/100 + ' g'; if (B17<0) { document.DCalcForm.B17.value='0 unit(s)'; } else { document.DCalcForm.B17.value=(Math.round(B17*100))/100 + ' unit(s)'; } if (B18<0) { document.DCalcForm.B18.value='0 unit(s)'; } else { document.DCalcForm.B18.value=(Math.round(B18*100))/100 + ' unit(s)'; } if (B19<0) { document.DCalcForm.B19.value='0 unit(s)'; } else { document.DCalcForm.B19.value=(Math.round(B19*100))/100 + ' unit(s)'; } if (B20<0) { document.DCalcForm.B20.value='0 unit(s)'; } else { document.DCalcForm.B20.value=(Math.round(B20*100))/100 + ' unit(s)'; } if (B21<0) { document.DCalcForm.B21.value='0 unit(s)'; } else { document.DCalcForm.B21.value=(Math.round(B21*100))/100 + ' unit(s)'; } if (B22<0) { document.DCalcForm.B22.value='0 unit(s)'; } else { document.DCalcForm.B22.value=(Math.round(B22*100))/100 + ' unit(s)'; } if (B23<0) { document.DCalcForm.B23.value='0 unit(s)'; } else { document.DCalcForm.B23.value=(Math.round(B23*100))/100 + ' unit(s)'; } if (B24>100) { document.DCalcForm.B24.value='100 %'; } else if (B24<0) { document.DCalcForm.B24.value='0 %'; } else { document.DCalcForm.B24.value=(Math.round(B24*100))/100 + ' %'; } if (B25>100) { document.DCalcForm.B25.value='100 %'; } else if (B25<0) { document.DCalcForm.B25.value='0 %'; } else { document.DCalcForm.B25.value=(Math.round(B25*100))/100 + ' %'; } if (B26<0) { document.DCalcForm.B26.value='0.00 g'; } else { document.DCalcForm.B26.value=(Math.round(B26*100))/100 + ' g'; } // document.write('B01 = '+B01+'<br>'); // document.write('B02 = '+B02+'<br>'); // document.write('B03 = '+B03+'<br>'); // document.write('B04 = '+B04+'<br>'); // document.write('B05 = '+B05+'<br>'); // document.write('B06 = '+B06+'<br>'); // document.write('B07 = '+B07+'<br>'); // document.write('B08 = '+B08+'<br>'); // document.write('B09 = '+B09+'<br>'); // document.write('B10 = '+B10+'<br>'); // document.write('B11 = '+B11+'<br>'); // document.write('B12 = '+B12+'<br>'); // document.write('B13 = '+B13+'<br>'); // document.write('B14 = '+B14+'<br>'); // document.write('B15 = '+B15+'<br>'); // document.write('B16 = '+B16+'<br>'); // document.write('B17 = '+B17+'<br>'); // document.write('B18 = '+B18+'<br>'); // document.write('B19 = '+B19+'<br>'); // document.write('B20 = '+B20+'<br>'); // document.write('B21 = '+B21+'<br>'); // document.write('B22 = '+B22+'<br>'); // document.write('B23 = '+B23+'<br>'); // document.write('B24 = '+B24+'<br>'); // document.write('B25 = '+B25+'<br>'); // document.write('B26 = '+B26+'<br>'); // document.write('BCR = '+BCR+'<br>'); // document.write('CSV = '+CSV+'<br>'); // document.write('NBG = '+NBG+'<br>'); } </script> </head> <body> <center> <form name=DCalcForm> <table name="table" id="table" class="table"> <tr name="01" id="01" class=""> <td name="A01" id="A01" class="inputlabel"> INSULIN/CARBOHYDRATE RATIO </td> <td name="B01" id="B01" class=""> <input name="B01" id="B01" class="inputbox" value="10" type="number"> </td> <td name="C01" id="C01" class=""> </td> </tr> <tr name="02" id="02" class=""> <td name="A02" id="A02" class="inputlabel"> INSULIN/BG RATIO </td> <td name="B02" id="B02" class=""> <input name="B02" id="B02" class="inputbox" value="35" type="number"> </td> <td name="C02" id="C02" class=""> </td> </tr> <tr name="03" id="03" class=""> <td name="A03" id="A03" class="inputlabel"> PROTEIN RATIO </td> <td name="B03" id="B03" class=""> <input name="B03" id="B03" class="inputbox" value="40" type="number"> </td> <td name="C03" id="C03" class=""> </td> </tr> <tr name="04" id="04" class=""> <td name="A04" id="A04" class="inputlabel"> FAT RATIO </td> <td name="B04" id="B04" class=""> <input name="B04" id="B04" class="inputbox" value="10" type="number"> </td> <td name="C04" id="C04" class=""> </td> </tr> <tr name="05" id="05" class=""> <td name="A05" id="A05" class="inputlabel"> TARGET BLOOD GLUCOSE </td> <td name="B05" id="B05" class=""> <input name="B05" id="B05" class="inputbox" value="100" type="number"> </td> <td name="C05" id="C05" class=""> </td> </tr> <tr name="06" id="06" class=""> <td name="A06" id="A06" class="inputlabel"> CORRECTION RANGE/SENSITIVETY </td> <td name="B06" id="B06" class=""> <input name="B06" id="B06" class="inputbox" value="20" type="number"> </td> <td name="C06" id="C06" class=""> </td> </tr> <tr name="07" id="07" class=""> <td name="A07" id="A07" class="inputlabel"> CURRENT BLOOD GLUCOSE </td> <td name="B07" id="B07" class=""> <input name="B07" id="B07" class="inputbox" value="100" type="number"> </td> <td name="C07" id="C07" class=""> </td> </tr> <tr name="08" id="08" class=""> <td name="A08" id="A08" class="inputlabel"> INSULIN ON BOARD </td> <td name="B08" id="B08" class=""> <input name="B08" id="B08" class="inputbox" value="0" type="number"> </td> <td name="C08" id="C08" class=""> </td> </tr> <tr name="09" id="09" class=""> <td name="A09" id="A09" class="inputlabel"> CARBOHYDRATES </td> <td name="B09" id="B09" class=""> <input name="B09" id="B09" class="inputbox" value="0" type="number"> </td> <td name="C09" id="C09" class=""> </td> </tr> <tr name="10" id="10" class=""> <td name="A10" id="A10" class="inputlabel"> PROTEIN </td> <td name="B10" id="B10" class=""> <input name="B10" id="B10" class="inputbox" value="0" type="number"> </td> <td name="C10" id="C10" class=""> </td> </tr> <tr name="11" id="11" class=""> <td name="A11" id="A11" class="inputlabel"> FAT </td> <td name="B11" id="B11" class=""> <input name="B11" id="B11" class="inputbox" value="0" type="number"> </td> <td name="C11" id="C11" class=""> </td> </tr> <tr name="12" id="12" class=""> <td name="A12" id="A12" class="outputlabel"> CARBS FROM PROTEIN </td> <td name="B12" id="B12" class=""> <input name="B12" id="B12" class="outputbox" value="" type="number" readonly> </td> <td name="C12" id="C12" class=""> </td> </tr> <tr name="13" id="13" class=""> <td name="A13" id="A13" class="outputlabel"> CARBS FROM FAT </td> <td name="B13" id="B13" class=""> <input name="B13" id="B13" class="outputbox" value="" type="number" readonly> </td> <td name="C13" id="C13" class=""> </td> </tr> <tr name="14" id="14" class=""> <td name="A14" id="A14" class="outputlabel"> TOTAL CARBOHYDRATES </td> <td name="B14" id="B14" class=""> <input name="B14" id="B14" class="outputbox" value="" type="number" readonly> </td> <td name="C14" id="C14" class=""> </td> </tr> <tr name="15" id="15" class=""> <td name="A15" id="A15" class="outputlabel"> CARBS TO BOLUS NOW </td> <td name="B15" id="B15" class=""> <input name="B15" id="B15" class="outputbox" value="" type="number" readonly> </td> <td name="C15" id="C15" class=""> </td> </tr> <tr name="16" id="16" class=""> <td name="A16" id="A16" class="outputlabel"> CARBS FOR EXTENDED BOLUS </td> <td name="B16" id="B16" class=""> <input name="B16" id="B16" class="outputbox" value="" type="number" readonly> </td> <td name="C16" id="C16" class=""> </td> </tr> <tr name="17" id="17" class=""> <td name="A17" id="A17" class="outputlabel"> CORRECTION BOLUS </td> <td name="B17" id="B17" class=""> <input name="B17" id="B17" class="outputbox" value="" type="number" readonly> </td> <td name="C17" id="C17" class=""> </td> </tr> <tr name="18" id="18" class=""> <td name="A18" id="A18" class="outputlabel"> PROTEIN BOLUS </td> <td name="B18" id="B18" class=""> <input name="B18" id="B18" class="outputbox" value="" type="number" readonly> </td> <td name="C18" id="C18" class=""> </td> </tr> <tr name="19" id="19" class=""> <td name="A19" id="A19" class="outputlabel"> FAT BOLUS </td> <td name="B19" id="B19" class=""> <input name="B19" id="B19" class="outputbox" value="" type="number" readonly> </td> <td name="C19" id="C19" class=""> </td> </tr> <tr name="20" id="20" class=""> <td name="A20" id="A20" class="outputlabel"> CARB BOLUS </td> <td name="B20" id="B20" class=""> <input name="B20" id="B20" class="outputbox" value="" type="number" readonly> </td> <td name="C20" id="C20" class=""> </td> </tr> <tr name="21" id="21" class=""> <td name="A21" id="A21" class="outputlabel"> TOTAL BOLUS </td> <td name="B21" id="B21" class=""> <input name="B21" id="B21" class="outputbox" value="" type="number" readonly> </td> <td name="C21" id="C21" class=""> </td> </tr> <tr name="22" id="22" class=""> <td name="A22" id="A22" class="outputlabel"> UNITS TO DELIVER NOW </td> <td name="B22" id="B22" class=""> <input name="B22" id="B22" class="outputbox" value="" type="number" readonly> </td> <td name="C22" id="C22" class=""> </td> </tr> <tr name="23" id="23" class=""> <td name="A23" id="A23" class="outputlabel"> UNITS TO EXTEND </td> <td name="B23" id="B23" class=""> <input name="B23" id="B23" class="outputbox" value="" type="number" readonly> </td> <td name="C23" id="C23" class=""> </td> </tr> <tr name="24" id="24" class=""> <td name="A24" id="A24" class="outputlabel"> PERCENT TO DELIVER NOW </td> <td name="B24" id="B24" class=""> <input name="B24" id="B24" class="outputbox" value="" type="number" readonly> </td> <td name="C24" id="C24" class=""> </td> </tr> <tr name="25" id="25" class=""> <td name="A25" id="A25" class="outputlabel"> PERCENT TO EXTEND </td> <td name="B25" id="B25" class=""> <input name="B25" id="B25" class="outputbox" value="" type="number" readonly> </td> <td name="C25" id="C25" class=""> </td> </tr> <tr name="26" id="26" class=""> <td name="A26" id="A26" class="outputlabel"> MORE CARBS NEEDED </td> <td name="B26" id="B26" class=""> <input name="B26" id="B26" class="outputbox" value="" type="number" readonly> </td> <td name="C26" id="C26" class=""> </td> </tr> </table> <br> <input type="button" value="Calculate" name="CalculateButton" onclick="Calculate()"> </form> </body> </html> P.S. I am by no means a professional and am aware that there might be better ways of doing this. I am still learning. |