function myFunc() { // some code to do with AJAX http_request.onreadystatechange = function() { // do some things return "a string"; }
}
alert(myFunc());
However, when I return "a string"; I want that string to be returned by myFunc() (and therefore alert'ed). What seems to be happening is that the string is being returned by the http_request.onreadystatechange = function() { } function, and myFunc() just returns false. How can I make the string be returned by myFunc()?
I'm looking to give viewers options for changing the colour scheme of a site. I've had a trawl through through the basic jQuery and UI capabilities, and it looks like toggleClass is the best option.
Has anyone other suggestions, from the range of other plugins?
The options will likely include changing the body backgound color, and background-image; changing text colour on certain classes; and changing the *content* of a div, which is the background layer for one area of the window.
I am building a site and I would like users to have the option of changing the colour scheme of the site. For example, you can have a 'red scheme' or a 'blue scheme' etc etc..
So, how can I produce a link to load new css files, that will return the current page with new css files?
I am using ASP.NET to develop this site, what would be the best to acheive this, Javascript? Code behind?
I found this script for a navigation fade-in/fade-out and I want to modify it so it'll only trigger the fade-in/fade-out functions of the span class is NOT set to active. Here is the javascript:
Code: $(function() { $("#nav ul#menu li span.active").css("opacity","1"); $("#nav ul#menu li span.active").hover("opacity","1");[code].....
It's the part of the code beneath the comment CONDITIONALS BELOW that I want to be able to only trigger it if span is not set to class .active.
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 have written a number of functions designed to return frequency data on 1000 randomly chosen numbers using different math functions for the rounding. I would like to include all of these functions within the wrapper of another function so that only one call is needed to get returns from all of the 'inner' functions. However, while each of the functions works in isolation, the moment I wrap them in another function they stop working. :confused:
The following code is one of the functions 'frequencyWrapperOne' that has been wrapped in the function 'testWrapper'. A call to testWrapper does nothing.
function testWrapper() { function frequencyWrapperOne() {
I have several form in my site, that validate on onsubmit.I call all the validation functions from a file call functions.js.Here is a sample of the code that is working:
I am reading the ECMAScript specs trying to figure out if the next line is a legal statement or not new Foo();
I think the above code may only be legal as an expression and not as a stand alone statement. Would this make the above a bug?
Douglas Crockford's JSLint will choke on the above line of code and stop parsing. All the browsers seem to accept it as ok and work as I expect: the returned object just doesn't get assigned to anything.
The time I have used a line like the above is when the constructor has side effects and the "class" keeps track of all its instances.
I have several text fields on page that I would like to make calculations based on if there is a number input in one of the fields. So, if the price field is populated, the sale price field would populate using a function to do the calculation.
Now, how do I write the code for this to occur? I know how to get the function to fire based on clicking a submit button, but not sure how to do it simply based on a number keyed into the one field. Is this possible and if so, how?
I have a two fold question:1) Why would my while statement not be workingI have cleaned up my code a little (although not perfect) but my while statement is not behaving, it does not output any numbers on a console.debug (using google chrome, or any other browser for that matter) which from my understanding it should?and 2) Slightly out of the remit of this forum I suppose, but this code is quite lengthy and I know there are ways to make this more efficient I just dont know what they are?
function generatePurchaseFields(dom) { new Ajax.Request('/control/?page=tldmaxyears&domain=' + dom, { method: 'get',
This is my first time using the switch statement. I would appreciate your suggestion on how to do this properly. I am trying to get customer age which is (age) and compare it with the monthly rate then the text msg will display in the textarea. Also, I am having trouble figuring out how I can defined my monthlyRate in the switch or do I need to this outside of the switch? Code: }
I am trying to test the id of three input boxes so that I can capitalize the first letter.
The fname and lname work fine but mi does nothing and I get no error is this because of the if statement or the fact that the mi only has one character?
I need to give two separate alerts depending on what the user clicks when they click the "Submit" button. I am using a confirm box. If they click "OK" it thanks them for their order. If they click "Cancel" it should go back to the form. I have written the code that I thought would work but it will not.
function confMsg(){ var s s = confirm("Click OK to Submit Order. Click Cancel to Cancel") if (s=="true"){ alert("Thank You for Your Order!") else return; }}