For the first time, I'm attempting to write a small Javascript program
using one on the online reference sites. I need some confirmation as
to the behaviour of the break statement.
In the following code:
for ( row = 0 ; row <= 7 ; row++ ) A <----
{
for ( col = 0 ; col <=7 ; col++ ) B <----
{
if ( check ( row, col ) == "pass" )
break ;
}
}
}
Where will control pass to once the break statement is executed?
Will it continue with the first 'for' statement (A) or the second (B)?
Also my 'check' function needs to pass an indication as to it's
success or failure. It does it by:
return ( "pass" ) ;
Am I doing it correctly?
Any links to useful reference sites would be welcomed.
this is a re-post of the last item in ':after in js?', below, but the problem is no longer about ':after': now there's an 'else if' statement that doesn't work. This works: it looks for 2 conditions in a class name, and changes a class:
Switch Create a HTML that uses Javascript. Create a page that tells a student the range their mark falls in if they know their letter grade. Below 50 is an "F", 50-59.9 is a D, 60 - 69.9 is a "C", 70 - 79.9 is a "B", 80 - 89.9 is an "A" and 90 - 100 is an "A+". You determine the input and output format.
<html> <!DOCTYPE HTML PUBLIC "-W3CDTD HTML 4.01EN"> <head> <title>Switch</title>
I have an input form that accepts numbers. I am trying to compare the last field value to the current field value. My problem is that when I use the variable name of the last field in an object path, I get the error "null or not an object". The var 'L' is the problem in the statement below. If I manually type the field name in place of 'L', it works fine. How do I have to write this statement so 'L' works?
I have a simple problem that I can't solve. I am trying to code a "More Info" button/link to display some more technical details of an item, if required or wanted. I haven't tried incorporating any code in to my web site yet, first I am trying to test how it can be done in a seperate file.
What I have right now is a table with two cells. In one cell is static text, in the other is a hyperlink. The onClick event calls a JS function called "more_info()" in which a global varible is altered to contain the value 1.
Directly after these two cells is more JS (this is before the table ends). The JS here is checking to see whether the value of the global variable has been changed. If the value is 1, display information. There is no "else" clause because I don't want information displayed unless the variable is equal to 1, so it is not required.
I think I know what the problem might be. The browser is reading the code in question before I ever click the link and has already been executed before the variable is changed. I know JS is object oriented so it will not sit there waiting for me to click the button before reading the logical statements.
I have a JavaServer demo I'm working on with a bit of JavaScript and thought I'd try adding some AJAX. Its a forum, and the idea is that a post window is revealed when the reply message is clicked. This button is in a jsp page has an onclick attribute to the showEditor() function below. A cancel button is similarly hooked up to hideEditor(), and the submit button calls copy() with a onsubmit tag. A servlet sends a response which has both the HTML for the post area (its a rich-text editor in an iframe, with a bunch of buttons above it much this one) and a Javascript object called Editor that has handlers for all the buttons and sets up the iframe so it is editable.
I actually got it to work okay, until I removed the last alert() I was using for debugging. Then the iframe stops being editable, and the editor.appendQuote() function either doesn't work or doesn't run.
This isn't terribly important because all AJAX accomplishes here is not sending all the post-related HTML and Javascript unless it is actually needed, which isn't all that much, but it would be nice to figure it out anyway.
Code: <script type="text/javascript"> var editor = null; function showEditor(node) { if (node != null) {
I am a novice, almost to an intermediate-level JavaScript guy, so much of this is new to me. I appreciate your patience reading this.
I have a routine that creates some HTML on the fly (updateFilters() function) and after the HTML is created, I attempt to access some fields (elements) on the form itself.
I works fine if I place an alert() statement after the HTML is created, but when I remove, the code errors out.
I have tried the setTimeout() statement, but I cannot grab the element --- undefined or null is returned. It seems that the form is the only element I can get a handle on --- everything else is undefined or null...
Here is the code:
function editQuery() { var f; var x; var myForm = document.forms[0]; // Get the row filters that were used in the last query.. for (f = 1; f < 16; f++) { var filter = eval("myForm.FilterList_" + f); if (filter.selectedIndex > 0) { var methodElement = element("FilterMethod_" + f); var methodIndex = methodElement.selectedIndex; var savedFilterMethodValue = methodElement.options[methodIndex].text; var choicesElement = element("FilterChoices_" + f); var choicesIndex = choicesElement.selectedIndex; if (isNaN(choicesIndex)) { var savedFitlerValues = choicesElement.value; } else { var savedFitlerValues = choicesElement.options[choicesIndex].text; } updateFilters(filter); // update the filters // take the saved methods and values and then update the selections // Alert here makes the code work.. // alert("Try this"); // Wait for HTML.. setTimeout("completeEdit()", 1000); function completeEdit() { // Since the object was updated, get the object again.. var methodElement = element("FilterMethod_" + f); for (x = 0; x < methodElement.options.length; x++) { if (methodElement.options[x].text == savedFilterMethodValue) { methodElement.options[x].selected = true; break; } else { methodElement.options[x].selected = false; } } // Since the object was updated, get the object again.. var choicesElement = element("FilterChoices_" + f); for (x = 0; x < choicesElement.options.length; x++) { if (choicesElement.options[x].text == savedFitlerValues) { choicesElement.options[x].selected = true; break; } else { choicesElement.options[x].selected = false; } } // Only display next row if f = 2.. // If only one row was used, no reason display the next row.. if (f == 2) { displayNextFilter(f - 1); // display it } } clearTimeout(timeOut); } } }
Do I have to pass the object (the form, the elements) to the completeEdit() function in the setTimeout() statement?
my webstie allows users to change the color of the background, so to keep the text readable I have it changing as well.the color picker I am using has text boxes with rgb values 0-255 for each.I am trying to get one bit of text to alternate between red and blue with the conditions
I'm using <DIV> tags to display some content with absolute positioning. The content sometimes goes more than 1 page. So i would like to have page break after 1 set of content is printed on a page. Its like this
<DIV id=A style="position:absolute; top:0px; left:0px; width:100px; height:100px"> Item One </DIV --do the page break <DIV id=A style="position:absolute; top:0px; left:0px; width:100px; height:100px"> Item Two </DIV
This should ensure that always the content is printed on the same position but in new page. The problem is how to do the page-break.
On a page I'm offering file download links which are each targeted to an tiny 1-pixel X 1-pixel iframe on the same page. (If you care why, see below.) Under certain conditions, I want to popup a window which is NOT constrained within the iframe to which its creator page is targeted. But since the download page is being targeted to the tiny iframe on the application page, any popups or alerts I've tried creating from the download page's code do not appear, presumably because they're being created inside the "invisible" iframe.
Is there any method for asserting on a page that a window or alert should NOT appear in the iframe to which the page was supposed to send its output? I'm developing in ASP.NET, so can modify page HTML and Javascript just before the page is sent to the browser.
The reason I'm targeting links to the tiny iframe is that when users select a file for download, the standard Windows open / save / cancel dialog pops up over the page they clicked rather than first opening a new "file download" page. When download is complete and the dialog disappears the original page remains ready for another user selection. The giant download site tucows.com uses this technique. However if there's another way to get this functionality I'm all ears!
1. User selects file for download on application page.
2. If no errors, standard Windows dialog pops up over application & download proceeds without changing application page. When download completes, dialog disappears and application page remains unchanged ready for further use.
3. If error, window or alert pops up over application. When closed, application page remains unchanged ready for further use.
Is it possible, when you have a loop in a loop, that when the inner loop reaches a certain point, it breaks out of both loops? For example:
[Code]....
The code above will break out of the (b=0;b<=10;b++) loop when b==5, but it will continue to do the a loop. not putting the first loop at all or making the first loop stop at 1): Is there a way to break out of both loops when the if condition is met? (I only ask that you not give a work-around because what I have in mind is much more complicated than this)
IE7/8 break effect when using a .png for the shadow under each colored block. The rest, including IE6 are fine with them. Note, IE6 has it's own problems, that I already fixed in my real page. Here is the test page >> Hover over the blocks in FX and now in IE7/8 >> Anyone see why IE is doing that to the shadow (i.e. blowing it up to ten times it's original size)?
If you take the comments out of the JS in the head section and use the full url .jpg one instead, then you will see that IE works just fine. It's only when using a .png that IE goes wrong. I guess if I have to I can try and make a jpg do in it's place, but it wont look as good, and I prefer not to.
I have the following code. When the user clicks on one of the links (Bookies Quick Search, Bingo Quick Search or Casino Quick Search), the submenus will appear underneath. This code works fine, however the only problem im having with this is that i cannot seem to get rid of the break inbetween each one. Code:
i have a nested loop in Javascript and i have a break statement in inner loop. As break statement takes control come out of inner loop. I want to come out of both loops if break statement reaches in inner loop. is there any way to do that ??
My code runs great in every browser but IE6 IE7 and IE8. it breaks and causes all scripts to fail. i setup Visual Web Developer in my VM like a blog post told me, and when i load the page i get Microsoft JScript runtime error: Object doesn't support this property or method that seem to break on this line
i am unable to break the line in javascript. Actually i am using a javascript to open Microsoft Outlook Express, And in the body text i am sending some value like "Name and Address(Shown in code)". I want after task it should break the line and the value of Address will start from new line. But i am unable to do that. The code i have used is given below.
// JScript File function EmailIt(emailTO,strAddress,strName) {
I'm using simple form validation, found online, to check certain fields before submitting. The problem is that, although the script detects the error/missing field/wrong syntax and pops up the corresponding alert, after the user presses OK in the alert box the script continues and sends the form - which of course is not valid.
I am using tinybox2 to make a modal window, which now I have loading correctly. the modal window loads as an iframe, but I have two image links inside the modal window. One I'd like to open in a new window (i got that one!), the other image I'd like to be treated the same as the X button and have it close the modal window.
this is the body onload in the main document <body onload="TINY.box.show({iframe:'modal.html',boxid:'frameless',width:750,height:450,fixed:false,maskid:'bluema sk',maskopacity:70,closejs:function(){closeJS()}})"> <script language="JavaScript1.2">mmLoadMenus();</script>
I have a lot of javascript for my google map api and I have all the information stored away in an xml file which the javascrupt reads. I have many map markers but I cannot get a line break between th esets of markers, only each and every marker. I tried this in the xml and in the javascript but I am stuck