JavaScript - Question About Onfocus
Hello
The onFocus events I have come across seem to deal with changing the background colour of the field on a Web form, so that the active field is a different colour to the background field of the other form elements. But how would I use onFocus simply to have the cursor moving in the active field (on a Web form it might be the 'name' field for example)? The code I have at the moment looks like this: Code: <!DOCTYPE etc <head> <title>Janko</title> <style type="text/css"> body { font-family: Arial, Sans-Serif; font-size: 13px; } #inputArea { font-family: Arial, Sans-Serif; font-size: 13px; background-color: #d6e5f4; padding: 10px; width:310px; } #inputArea input, #inputArea textarea { font-family: Arial, Sans-Serif; font-size: 13px; margin-bottom: 5px; display: block; padding: 4px; width: 300px; } .activeField { background-image: none; background-color: #ffffff; border: solid 1px #33677F; } .idle { border: solid 1px #85b1de; background-image: url( 'blue_bg.png' ); background-repeat: repeat-x; background-position: top; } </style> <script src="jquery-1.2.6.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $("input, textarea").addClass("idle"); $("input, textarea").focus(function(){ $(this).addClass("activeField").removeClass("idle"); }).blur(function(){ $(this).removeClass("activeField").addClass("idle"); }); }); </script> </head> <body> <h2><a href="www.jankoatwarpspeed.com">Janko At Warp Speed</a></h2> <p>This example is from the article <a href="http://www.jankoatwarpspeed.com/post/2008/05/22/CSS-Message-Boxes-for-different-message-types.aspx">Enhance your input fields with simple CSS tricks</a></p> <div id="inputArea"> <label for="txtName"> Name</label> <input id="Text16" type="text" /> <label for="txtEmail"> Email</label> <input id="Text17" type="text" /> <label for="txtWebsite"> Subject</label> <input id="Text18" type="text" /> <label for="txtComment"> Message</label> <textarea id="Textarea6" rows="4" cols="30"></textarea></div> </body> </html> Many thanks Steve Similar TutorialsHi all, I have a REALLY strange problem - maybe a new set of eyes can help me. Look at these pieces of code: This generates the code Code: <!-- BEGIN code_open --> <dl class="codebox"> <dt>{L_CODE}: <a href="#" onclick="autoSelect(this.parentNode.nextSibling); return false;">{L_SELECT_ALL_CODE}</a> </dt> <dd> <pre onfocus="doTest(this)"> <!-- END code_open --> <!-- BEGIN code_close --> </pre> </dd> </dl> <!-- END code_close --> Test JS just for now Code: var doTest = function(a) { alert(a); } The HTML as seen by Firebug Code: <dt>Code: <a href="#" onclick="autoSelect(this.parentNode.nextSibling); return false;">Select all</a></dt><dd> <pre onfocus="doTest(this)"> Test Test Test </code></pre></dd> One little problem... it doesn't work!!! And yes the function being called is accessible. For that matter, simply putting "alert('hello')" into the "onfocus" also fails. I even checked at W3CSchools to verify that: (1) The <pre> element supports "onfocus" (it does). (2) I ran their "Try it" and "onfocus" is working in my browser (Firefox 3.6.17, WinXP 32). What the heck??????????? Any ideas? Thanks! -- Roger greetings, i have a function that sets the onfocus and onblur event for every item in a table which then tells it to the change the class name. for some reason this doesn't seem to be working with the <select> inputs. i have heard it has something to do with how the option list re-loads itself??? Code: function setTableActivation(){ tableDiv = document.getElementById("tables"); tables = tableDiv.getElementsByTagName("table"); count = tables.length; for(var h=0;h<count;h++){ var table = tables[h]; table.accessKey = h; table.onfocus = function(){tables[this.accessKey].className = "activeTable";}; table.onblur = function(){tables[this.accessKey].className = "searchreal";}; for(var i=0;i<table.rows.length;i++){ row = table.rows[i]; row.accessKey = h; row.onfocus = function(){tables[this.accessKey].className = "activeTable";}; row.onblur = function(){tables[this.accessKey].className = "searchreal";}; for(var j=0;j<table.rows[i].cells.length;j++){ cell = table.rows[i].cells[j]; cell.accessKey = h; cell.onfocus = function(){tables[this.accessKey].className = "activeTable";}; cell.onblur = function(){tables[this.accessKey].className = "searchreal";}; for (var k = 0; k < cell.childNodes.length; k++) { if (cell.childNodes[k].nodeType == document.ELEMENT_NODE) { cell.childNodes[k].accessKey = h; cell.childNodes[k].onfocus = function(){tables[this.accessKey].className = "activeTable";}; cell.childNodes[k].onblur = function(){tables[this.accessKey].className = "searchreal";}; if(cell.childNodes[k].tagName == "SELECT"){ } } } } } } } Hi, can someone show me why I cant get the onfocus and onblur to loop thru the function showTextContent() when entering the words one, two, three or four. I have tried for days, googled and lost a lot of hair trying to figure it out. http://www.data-affiliates.com/DL234...5/attempt.html Code: <html> <!-- Created on: 08.08.2009 --> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title></title> <meta name="description" content=""> <meta name="keywords" content=""> <meta name="author" content="sdfgdfg"> <meta name="generator" content="AceHTML 6 Pro"> <link rel="stylesheet" href="vid61.css" type="text/css" media="screen" /> <script type="text/javascript"> function toggle(id, status){ document.getElementById(id).style.visibility = status; } function myFocus(element) { if (element.value == element.defaultValue) { element.value = ''; } } function myBlur(element) { if (element.value == '') { element.value = element.defaultValue; } } function populateSearchField(){ var specialChars = "\\.+*?[^]$(){}=!<>|:,-=/"; var ignoreList = ["a", "the"]; var i, j, searchFld, keywords; if (!(searchFld = document.getElementsByName('formcontent')[0])) return; if (!(keywords = document.referrer.match(/[pq]=(.*?)&/))) return; var preg_quote = function(str){return (str+'').replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!<>\|\:])/g, "\\$1");} keywords = decodeURIComponent(keywords[1]).replace(new RegExp('[' + preg_quote(specialChars) + ']', 'g'), ' ').split(/[\+ ]/); for (i = 0; i < keywords.length; i++){ for (j = 0; j < ignoreList.length; j++) if (!keywords[i] || (keywords[i] == ignoreList[j])) { keywords.splice(i--, 1); break; } } searchFld.value = keywords.join(' '); } function keywordMatch(keywords, text) { var result = 0; for (var i in keywords) { if (text.match(new RegExp("(^| )" + keywords[i] + "( |$)", "i"))) { result++; }; } return result; } function showTextContent() { var i, matches = []; var div, divcontent, divs = document.getElementById("ts-1").getElementsByTagName('div'); var keywords = document.getElementsByName('formcontent')[0].value.split(' '); for (i = 0; i < divs.length; i++) { div = divs[i]; divcontent = div.lastChild.nodeValue; if (keywordMatch(keywords, divcontent)) { matches.push(div); } } if (matches[0]) { document.getElementById('take1000').innerHTML = matches.length + " matches / Treffer"; for (i = 0; i < matches.length; i++) { matches[i].onmouseover(toggle('take1000', 'visible')); matches[i].onmouseout = null; } } else { document.getElementById("ts-1").innerHTML = "" ; matches[i].onmouseover(toggle('notake1000', 'visible')); } } window.onload = function(){ populateSearchField(); showTextContent(); } </script> </head> <body> <div id="container"> <div id="notake1000">Keine Ergebnisse / No Matches</div> <div id="take1000"></div> <div id="ulent">Search this site / Diese Seite durchsuchen :</div><form><input type="text" name="formcontent" value="one" onmouseover="toggle('notake1000', 'hidden');toggle('take1000', 'hidden');" onfocus="myFocus(this); showTextContent();" onblur="myBlur(this); showTextContent();" style="font-family:Arial;color:#ffff40;text-align:center;font-size:12px;font-weight:bold;float:right;margin-left : auto;margin-right : 2px;border: 2px double #AFAFAF;background-color: #5F5F5F;padding:1px;height:18px;width:293px;" /></form> <div id="ts-1" style="visibility:hidden;"> <div onmouseover="toggle('fo-test1', 'visible');" onmouseout="this.className='ts-1-1';toggle('fo-test1', 'hidden');" onmouseup="this.className='ts-1-3A';" class="ts-1-1"><object id="fo-test1" style="visibility:hidden;" type="application/x-shockwave-flash" data="peelawayok.swf" width="356" height="286"><param name="movie" value="peelawayok.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="false" /></object>www.Ihre-domain.de<br />one</div> <div onmouseover="toggle('fo-test2', 'visible');" onmouseout="this.className='ts-1-2';toggle('fo-test2', 'hidden');" onmouseup="this.className='ts-1-3A';" class="ts-1-2"><object id="fo-test2" style="visibility:hidden" type="application/x-shockwave-flash" data="peelawayok.swf" width="356" height="286"><param name="movie" value="peelawayok.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="false" /></object>www.Ihre-domain.de<br />two</div> <div onmouseover="toggle('fo-test3', 'visible');" onmouseout="this.className='ts-1-3';toggle('fo-test3', 'hidden');" onmouseup="this.className='ts-1-3A';" class="ts-1-3"><object id="fo-test3" style="visibility:hidden" type="application/x-shockwave-flash" data="peelawayok.swf" width="356" height="286"><param name="movie" value="peelawayok.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="false" /></object><br />www.Ihre-domain.de<br />three</div> <div onmouseover="toggle('fo-test4', 'visible');" onmouseout="this.className='ts-1-4';toggle('fo-test4', 'hidden');" onmouseup="this.className='ts-1-3A';" class="ts-1-4"><object id="fo-test4" style="visibility:hidden" type="application/x-shockwave-flash" data="peelawayok.swf" width="356" height="286"><param name="movie" value="peelawayok.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="false" /></object><br />www.Ihre-domain.de<br />four</div> </div> </div> </body> </html> Hey all, I'm trying to write what I thought to begin with would be a simple script. All it will do is go out and find every textarea, then change the onblur/onfocus functions to something that I created. Here's my problem, when I am going through each textarea object, I can't seem to find a way to reference the object from within the function. See down in that for loop? When I say tAreaSniffer(i), the i ends up being overwritten each time. This makes the value of i in each object to be 3(since there are 3 textareas). I have used javascript in the past, however now I am getting back into it and having trouble. Thanks guys, Here's my code: Code: <html> <head> </head> <body> <form> <textarea name="t1" rows="4" cols="20"></textarea> <textarea name="t2" rows="4" cols="20"></textarea> <textarea name="t3" rows="4" cols="20"></textarea> </form> <script type="text/javascript"> var sniffer; var textareas = document.getElementsByTagName('textarea'); var counter = 0; function tAreaSniffer(tArea)//, oldCont) { alert(tArea); //var curCont; = tArea.value; counter++; sniffer = setTimeout(function(){tAreaSniffer(tArea)}, 1000); } for(var i=0; i<textareas.length; i++) { textareas[i].onfocus = function(){tAreaSniffer(i);};//, textareas[i].value);}; textareas[i].onblur = function(){clearTimeout(sniffer);}; } alert("HEYO"); </script> </body> </html> Hi, I'm working on a website and am having difficulty figuring out how to have a function triggered when the window becomes active. I am having limited success with: <body onFocus=myFunction();> This works fine with Firefox and Safari, but not Internet Explorer. Is there a way to achieve this in all 3 browsers? Thanks. Realizing that form input placeholders aren't universally recognized among browsers, I began changing all of mine using onblur and onfocus handlers instead. As an example, I used the following code, which works in most cases: Code: <input type="text" name="example" maxlength="5" value="Example" onblur="if(this.value=='') this.value='Example';" onfocus="if(this.value=='Example') this.value='';"/> At first, I coded all of the inputs without a value attribute. But, when the page initially loaded, the fields would load empty, and the value/placeholder wouldn't appear until the field had been "focused" and then "blurred" again. Adding the value attribute seemed to correct that problem, again, for the most part. I have some text fields that appear only after I select a particular radio button or select option. Problem is, when the radio is clicked, the field appears, but even with the value attribute in place, the field appears void. I'm not sure what is different, or what I'm doing wrong. Here's the javascript code with the radio button (note:everything works except that the "placeholder" doesn't show when the field first appears): Code: function showfield() { document.forms[0].otherRelation.value = ""; document.getElementById("newBox").style.display = "none"; var r = document.forms[0].relation; var len = r.length; for (var i =0; i<len; i++) { if (r[i].checked && r[i].value == "Otherrelation" ) { document.getElementById("newBox").style.display = "inline"; } } } <input type="radio" name="relation" value="Otherrelation" onclick="showfield()"/>Other <span id = "newBox" style="display:none">: <input type = "text" name="otherRelation" size="35" value="Your Relationship" onblur="if(this.value=='') this.value='Your Relationship';" onfocus="if(this.value=='Your Relationship') this.value='';"/> </span> Thanks for any help. Sorry so long. I am trying to get a text field to increase in size (one time to a predetermined size) when user clicks in the text field. Here is the code that for some reason isn't working for me. Code: <script type='text/javascript'> function resizeIt() { document.getElementById('comment').style.height = 50px; }; </script> <input type='text' id='comment' class='urlTextArea' name='url' value='' size='75' onfocus='resizeIt()'> Hi all, I am working on a site which is in a frameset. There is content area, a footer and a workqueue on the right. Now what I do is poll the workqueue every 30 seconds, check if there are any changes to any queues and if so, I make them go bold and red and play a beep. That's no problem, that works fine. The trouble is I am trying to make the title flash "New Item" if the window is out of focus (Minimised would be better but dont think that is possible to detect). The flashing bit is no problem, it's the triggering when the windows out of focus that is a problem. Applying events to the window object doesn't work. The closest I have come to making it work is this, but it doesn't work in firefox... Code: var debugwin = window.open("", "newwin", "width=300, height=300, scrollbars=1"); debugwin.document.open(); debugwin.document.write("<HTML><TITLE>Debug Window</TITLE><BODY>"); debugwin.document.write("</BODY></HTML>"); debugwin.document.close(); function addDebug(msg) { debugwin.document.body.innerHTML = msg + "<BR/>" + debugwin.document.body.innerHTML; } <!--<frameset onblur="workitemAlerts.setItemAlerts(false);" onfocus="workitemAlerts.setItemAlerts(true);" id="titleframeset" rows="<%= HEADER_FRAME_RESTORED %>,*,<%= FOOTER_FRAME_HEIGHT %>" framespacing="0" border="0" frameborder="0">--> <frameset onblur="addDebug('Blur 1st frameset');" onfocus="addDebug('Focus 1st frameset');" id="titleframeset" rows="<%= HEADER_FRAME_RESTORED %>,*,<%= FOOTER_FRAME_HEIGHT %>" framespacing="0" border="0" frameborder="0"> <frame onblur="addDebug('Blur frame 1');" onfocus="addDebug('Focus frame 1');" noresize scrolling="no" framespacing="0" border="0" frameborder="0" id="titlebar" name="titlebar" src="<wfmt:headerpage />"> <frameset onblur="addDebug('Blur 2nd frameset');" onfocus="addDebug('Focus 2nd frameset');" id="mainframeset" cols="10,*,<%= MAIN_FRAME_RESTORED %>" framespacing="0" border="0" frameborder="0"> <frame onblur="addDebug('Blur frame 2');" onfocus="addDebug('Focus frame 2');" noresize framespacing="0" border="0" frameborder="0" name="leftpad" src="mainColourFill.jsp" scrolling="no"> <frame onblur="addDebug('Blur frame 3');" onfocus="addDebug('Focus frame 3');" noresize name="windmain" src="<wfmt:postloginpage />" scrolling="auto"> <frame onblur="addDebug('Blur frame 4');" onfocus="addDebug('Focus frame 4');" noresize framespacing="0" border="0" frameborder="0" name="queues" src="workqueues.jsp" scrolling="no" style="BORDER-RIGHT: gray 1pt solid;"> </frameset> <frame noresize scrolling="no" framespacing="0" border="0" frameborder="0" name="footerbar" src="footer.jsp"> </frameset> I have popped up a little window to help me view debug away from the window so I can focus and blur and still see the output to see what events are triggering. IE seems to trigger the events on the <frame> tags fine, which means I can achieve what I need to in IE, however FF isn't playing ball. Anybody know what I can do to detect if the window is out of focus. TIA, Dale Can we have two onFocus javascriptscript events for single HTML Tag? Thank you..
Hi I've just found out that a piece of code is not working as expected in certain browsers - but the way in which it goes wrong is not consistent, so maybe it's something wrong with my code. Oddly enough, it works exactly as I was expecting when viewed in IE. Here's the code... any help would be much appreciated. Thanks Code: <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script type="text/javascript"> function fillboxAddress() { if (document.getElementById('tbAddress').innerHTML == '') { document.getElementById('tbAddress').innerHTML = 'Address'; } } function clearboxAddress() { if (document.getElementById('tbAddress').innerHTML == 'Address') { document.getElementById('tbAddress').innerHTML = ''; } } </script> </head> <body> <p><textarea name="tbAddress" rows="2" cols="20" id="tbAddress" onfocus="clearboxAddress()" onblur="fillboxAddress()">Address</textarea></p> </body> Hi, I'm having some problems with some javascript events firing in the wrong order under certain workflows. Here's the gist of it: I have a form with many fields, mostly input type = text. Each field as an OnBlur and OnFocus event tied to javascript functions. IE's website (http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx) states that "The onblur event fires on the original object before the onfocus or onclick event fires on the object that is receiving focus." and that is exactly what happens when tabbing through the fields. The tricky part is that it doesn't perform this way when CLICKING to another field. When clicking to another field it performs the new field's OnFocus first, and then the first field's OnBlur event after. This is bad because the OnFocus sets a global variable's value to whatever value is in that box at the time it gets focus and if the onblur validation fails, that value is inserted back into the box. So what's happening is the validation for field 1 fails and the value from field 2 is then written into field 1. This also seems to only happen when the page is opened as a modal window as opposed to just opening the page on it's own. It doesn't happen in FireFox, I've only been able to get it to happen on IE 8 + (haven't tried any other browsers.) Anyone else have this happen to them? Does it sound like an IE bug? Thanks Hi- I have a table with numerous textareas that I am able to clear once - the first time the textarea is clicked the default value is cleared and everything is OK. However, at a certain point the user might press a 'Clear' button linked to a function I wrote to reset the values back to the defaults. At this point clicking into the textarea does not clear it. Below is a typical textarea: Code: <textarea rows= "2" cols="15" class="Klabel" id="ta5" onfocus="this.value=''; this.onfocus=null; setbg_color('ta5','#EFA746')" onchange="setbg_color('ta5', '#EBF5FF')"> Type a label </textarea> Below are the relevant functions. The Clear function mentioned above just runs 'setbg_color' and 'set_value' for each textarea and sets them to the defaults. Code: function setbg_color(id, color){ document.getElementById(id).style.background=color; } function set_value(id, celltype){ document.getElementById(id).value=celltype; } Is there anyway to essentially reverse the effects of the this.onfocus=null; statement? I tried something like this.onfocus=true; but that didn't work. An update - I haven't answered the reversing null question but an acceptable solution is to reload the page from within javascript as per http://www.mediacollege.com/internet...ge/reload.html Thanks -Jim ps - As part of my research I came across this http://mvied.com/blog/unobtrusive-input-clear-focus/ which does a smoother job of clearing the textareas but does not solve my question. Hey guys, First shot at JS so please be gentle! I'm trying to get this script to clear the default value of my input elements on focus. It works well the first time, however, if a user inputs some fresh text, selects something else, then selects the same input element again, it will clear the text they entered. Make sense? Here's the script (thanks in advance!!): Code: <script language="JavaScript"> function clickFocus(input){ input.className = 'focus'; if (input.value = input.defaultValue){ input.value = ''; } } function unFocus(input){ input.className = 'entered'; if (input.value == ''){ input.value = input.defaultValue; input.className = 'normal' } } </script> <form action="confirmation.php" method="post" enctype="multipart/form-data" name="form" id="form" onsubmit="return checkForm(this)"> <input type="text" name="name" value="Name" onfocus="clickFocus(this)" onblur="unFocus(this)" /> <input type="text" name="email" value="Email" onfocus="clickFocus(this)" onblur="unFocus(this)" /> <input type="text" name="subject" value="Subject" onfocus="clickFocus(this)" onblur="unFocus(this)" /> <textarea type="text" name="message" onfocus="clickFocus(this)" onblur="unFocus(this)" rows="5">Message</textarea> <input class="submit" name="submit"type="submit" value="Send Message" /> </form> hello all ive been asked to create a javascript slideshow.... and i don't really understand it that much i know a little javscript but not much........ is thier any helpful sites that i can use to teach you step by step to make a javascript slide show???? also if don't want loads of code to be used, i want the code to be clean insted of loads and loads of code what is just unessary. i will be linking the javascript file to the html file so i need to keep the code to a min LOL CHEERS Ok i have been working on this for a while now. I have to have 3 fish swim across the screen in both direction. I have tried a few things but nothing is working. Can someone please explain to me what I am doing wrong. here is my code for you guys to look at it. Code: <!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> <title>Fish tank</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript"> // <![CDATA[ var fishPos = new Array(3); fishPos[0] = "fish1.gif"; fishPos[1] = "fish2.gif"; fishPos[2] = "fish3.gif"; var fillPosition = 10; for(var i = 0; i < 50; ++i) { horizontal[i] = fillPosition; fillPosition += 10; } function fishSwim(fishNumber) { document.getElementById("fishPos").style.left = horizontal + "px"; ++fishPos[fishNumber]; if (fishPos[fishNumber] == 49) fishPos[fishNumber] = 0; } function startSwimming() { setInterval(fish1Swim, 100); } // ]]> </script> </head> <body onload="startSwimming();"> <p><span id="fish1" style= "position:absolute; left:10px; top:10px"><img src="fish1.gif" alt="Image of a fish" /></span></p> <p><span id="fish2" style= "position:absolute; left:10px; top:120px"><img src="fish3.gif" alt="Image of a fish" /></span></p> <p><span id="fish3" style= "position:absolute; left:10px; top:250px"><img src="fish2.gif" alt="Image of a fish" /></span></p> </body> </html> I am really not understanding and in my book it only give me a page to read about the animation. I am still new to it. Thanks for looking Hi all I am doing an assigment and have gotten to the end and cannot get the unordered list to work. If I try having my </script> tag below the </ul> it does not display anything If i have it above it will only display the varible names or what ever I type between the <li> </li> tag and not the varible assigment. num1,2,3,4 being the varible name. ie. </script> <ul> <li>num1</li> I have tryed <li>+num2+</li> also tryed <li>(num3)</li> also tryed <li>'num4'</li> also tryed and does not display </ul> </head> </html> The following does not display any thing <ul> <li>num1</li> I have tryed <li>+num2+</li> also tryed <li>(num3)</li> also tryed <li>'num4'</li> also tryed </ul> </script> </head> </html> I need to get the <li></li> to display not what I type in there but the assigment of the varible name I put in there.,or the output the varible calculation produces. Hope that was easy to understand lol Any advise would be awesome, cheers Shayne Darcy. Could someone please take a look at my code? It's a simple quiz with one multiple choice question and one fill in the blank. When the user clicks on 'submit' I tried to show some kind of response with correct/incorrect images next to the question. It works with the multiple choice question, but not with the fill in the blank. How can I get the fill in the blank question to work. It always shows the answer as being wrong. Thank you. Quote: answer_list = [ ['False'], ['body','hips','knees'] // Note: No comma after final entry ]; response = []; function setAnswer(question, answer) { response[question] = answer; } function CheckAnswers() { var correct = 0; var flag, resp, answ; for (var i = 0; i < answer_list.length; i++) { flag = false; for(var j=0; j<answer_list[i].length; j++){ resp = response[i].toLowerCase(); answ = answer_list[i][j].toLowerCase(); ################################################################################################# if (response[0] == answer_list[0]) { flag = true; document.myquiz.a1c.style.backgroundImage="url('correct.gif')"; } else{ document.myquiz.a1c.style.backgroundImage = "url('incorrect.gif')"; document.myquiz.a1c.value = " ANS: False. Position the head snugly against the top bar of the frame and then bring the foot board to the infant's feet."; } if (response[1] == answer_list[1]) { flag = true; document.myquiz.a1d.style.backgroundImage="url('correct.gif')"; } else{ document.myquiz.a1d.style.backgroundImage = "url('incorrect.gif')"; } ################################################################################################### } if (flag) { correct++; } } document.writeln("You got " + correct + " of " + answer_list.length + " questions correct!"); } </SCRIPT> </HEAD> <FORM name="myquiz"> <B>1. When measuring height/length of a child who cannot securely stand, place the infant such that his or her feet are flat against the foot board.</B> <label><INPUT TYPE=radio NAME=question0 VALUE="True" onClick="setAnswer(0,this.value)">True</label> <label><INPUT TYPE=radio NAME=question0 VALUE="False" onClick="setAnswer(0,this.value)">False</label> <textarea rows="2" cols="85" name="a1c" style="background-repeat:no-repeat"></textarea> <B>2. When taking a supine length measurement, straighten the infant's <INPUT id="test" TYPE=text NAME=question1 size=10 onChange="setAnswer(1, this.value)">, <INPUT id="test" TYPE=text NAME=question1 size=10 onChange="setAnswer(1, this.value)">, and <INPUT id="test" TYPE=text NAME=question1 size=10 onChange="setAnswer(1, this.value)">.</B> <textarea rows="2" cols="85" name="a1d" style="background-repeat:no-repeat"></textarea> <INPUT TYPE="button" NAME="check" VALUE="Check Answers" onClick=CheckAnswers()> </FORM> </div> </FONT> </BODY> </HTML> You are given a mathematical expression containing integers and the basic operations: *,+,-, /. Find the number of unique results that can be obtained by parenthesizing the expression differently. i.e., by changing the order of evaluation of the operations. Note that all operations are integer operations. For example, if the input is 2 ∗ 3 + 6/2, your output should be 4. Plzz help me with this qs......... I'm not sure if this is the correct forum or not, but here goes. I want to make a very simple XUL document. Just a simple basic window to be opened up, but, i want the XUL to Load and Render an HTML File. I'm not sure about what function(s) to call to achieve this, can anyone give me any ideas to go on? here's what i have so far use my JavaScript Function called LoadFromDisk(FileName), if the file is there or the load is sucessfull, it can be stored as a variable. And then i have a single Division in the XUL document called RenderWindow. From there i set the innerHTML of the RenderWindow to the data that was loaded from the disk. Is this the right way? thanks I was asked to redo a menu for this site: http://www.listlabs.com/index.php It was originally an imaged based menu, but they wanted it all changed to css/html. I used quickmenu and it used JS to produce the arrows at the top of each menu item. Now to my question... I'm trying to program the menu items to stay active when on the current page. At first, it looks correct, but if you hover back over the menu, it changes back to the inactive state. Any help would be great! Thanks. |