I am try to make a form that appears to be multi page. I am trying to use a button to hide one div and display another at the same time my script is
head <script language=javascript type='text/javascript'> function hidediv(pass) { var divs = document.getElementsByTagName('div'); for(i=0;i<divs.length;i++){
Has anyone an idea, if my thoughts on that are correct oder if this behaviour could be a problem? And is there probably a better way to combine functions, so that all functions would be in one column?
This is probably more of a basic javascript question than a specificjquery function.I have this jQuery function named validateSubmit()which calls two other regular javascript functions. When using IE,both createCharts() and getDirectorIDs get called but when usingFireFox, only createCharts() gets called and never makes it togetDirectorIDs() and I'm not sure why this occurs.
<script type="text/javascript"> // make sure at least one checkbox is checked function validateSubmit() {
I'm trying to build a t-shirt creator application w/ php and ajax.You can see where I'm at here.Thus far, I've successfully passed the first parameter from the form via a function called from an onchange event, which uses a php script to pass simple text (for the time being, 'til i get this figured out), which you can see working on the page.trying to update the output w/ each change they make via the form. For every step, the output on the right needs to update.Should I be calling the same function for each onchange, or different functions? Here's what I'm using as far as AJAX/form goes:
Code: function showShirt(s) { // CHECKS IF THE STRING IS EMPTY if (s=="") {[code]...........
I want to learn more about creating functions for element events without having to put onclick event in every tag. For example:
<script> document.getElementsByTagName('input').onclick = function () { alert('hello'); } </script>
Now, I know the above does not work as I have tried it but hopefully the idea of what I am trying to achieve here. Basically for every input tag, when the user triggers the event (click) it will do the same function.
Anyway, I would more so like to learn about this type of scripting where you assign functions to events. However, I dont know what to search for in google and the like. Where could I learn more about this?
I have a nproblem with running commands from a loaded page;[code]Now i want to execute the alert() on page BB.html when doing the load on page AA.html.
I totally understand that in order to learn javascript I need to know how functions work, I understand the basics of passing in parameters and then calling the function with the values to maybe add something together etc I ve read countless articles about functions as well as books etc but I just dont get how they are used and when they should be used etc, the more advanced functions that have maybe 4 parameters and are doing different calculations and returning various values that get fired back into the script just totally confuses me.
What I would like to know is first of all how can I overcome this confusion and also any words of wisdom you may have. I will also add that I have no prior programming experience and have spent the last 2 months frequently hitting my head off a brick wall as I just cant understand javascript.
but i have these basic functions to show a div and all i would like to do after these run is to actually make the screen scroll to the bottom here is my code i know is wrong can you please point me in the right direction.
I can't seem to get the syntax correct to get this to work. I'm sure it is something simple.I want to call multiple functions inside my document.ready function.The first function gets called but not the second.
$(document).ready( function GetSuspectCollection() { $.ajax({[code].....
I am confused about the true difference between the two below examples.
first example:
// Demonstrating a problem with closures and loops var myArray = [“Apple”, “Car”, “Tree”, “Castle”]; var closureArray = new Array();
[code]....
Here we iterate through the length of myArray, assigning the current index of myArray to theItem variable. We declare closureArray 4 times as an anonymous function. The anonymous function in turn declares the predefined write() function, which is passed parameters. Since write() is in closureArray() a closure is created??? During each iteration, theItem is reassigned its value. The four closures reference this value. Since they reference this same value and since this value is reassigned ultimately to the value of the fourth index position, tHe time we execute closureArray later on, all four closures output the same string. This is because all four closures are within the same scope "the same environment" and therefore are referencing the same local variable, which has changed.
I have a couple of problems with this example:
1) I thought a closure is a function that is returned - the inner function is not returned above.
2) theItem is not even a local variable of the parent function (closureArray) - I thought in order for a closure to work, the inner function only accesses the local variables of the outer function, but in this case the local variable is defined OUTSIDE of the parent function.
3) the "the four closures are sharing the same environment." The thing is even in the second example, they are sharing the same environment.
Second example:
// A correct use of closures within loops var myArray = [“Apple”, “Car”, “Tree”, “Castle”]; var closureArray = new Array();
[code]....
Here we iterate over the length of myArray (4 times), assigning the index of myArray to theItem variable. We also return a function reference to the closureArray during each iteration (closureArray[i]), where i is index number so we assign 4 functon references. So when we iterate through myArray, we immediatelly call the writeItem() fucntion passing an argument of theItem at its current value. This returns a child anonymous function and when that child function is called, it will execute a block that calls the predefined write() method. We assign that returned anonymous function to the variable closureArray. Hence, closureArray holds a reference to that anonymous function. So closureArray during each iteration holds a reference to the anonymous function and we later call closureArray, which in turn calls the anonymous function, therefore calling the predefined write() function to output the local variable of the parent function. This outputs each distinct index of myArray.
This is because since we created the closure, when we call writeItem, passing theItem argument, since theItem is a local variable of the parent function of the closure, it is never destroyed when we later call closureArray (the reference to the child anonymous function)? Yet weren't we using a closure in the first example as well? So whey wasn't those variables preserved?
I don't think it has anything to do with assigning a returned anonymous function to closureArray. Even though an anonymous function creates a new memory position in the javascript engine, therefore not overwriting the other function references we create during the iteration, it's still referring to a local variable declared outside the reference. So if it's about the closure retaining value of parent's local variable even after exiting the parent function allowing for the current indexes to be preserved, then why did the closure in the first example fail to retain each index?
I am interested in using real time analytics and also stuff like heat map software on my site for my small business however, I am worried about the amount of extra calls it will take by adding these new scripts..
I read that its possible to put them onto one and call it once..
How would i do this? Is this also possible for JS plugins as well (wordpress user)
I'm a js novice and I've been trying to implement a few scripts. I was able to get them to function for the most part.
[URL]
I have the following 3 plugins:
1. accordion menu that drops down to show filter categories
2. a gallery filter to filter out images in a category once it is clicked on,
3. Magic Zoom Plus to zoom in on an enlarged image and to provide a lightbox gallery where you can click the arrow to advance to the next image.
The filter works for the thumbnails, but there is an issue when you click on a thumbnail to enlarge it and it opens the Magic Zoom Plus gallery. When you click on the arrows to go forward & back, it is taking you through all of the images, where it should just be the ones that in that category. I know that the Magic Zoom Plus gallery works on all the images on a page. I assume that in order to get the gallery feature to apply to a category & not the whole page, there would have to be some changes the Magic Zoom Plus script.
I was wondering if there was any easy way to do the following in javascript:
I have two form fields, firstname and last name, as the user enters their information into a form I want to be able to show them what their username is going to be.
While they enter the information into the fields I was hoping to have it generate the username as the type.
I need to take the first letter of their first name (the first letter in the firstname field) and the entire lastname to combine it into a username. Except if there are spaces or any other characters such as dashes apostrophes they must be removed.
My site loads too many javascript files and it takes much time to load page. I would like to reduce the number of http requests and combine all javascript files into one file. What is the best way for it? Will it work if I just copy whole code from all files and paste into one or anything else is needed?
I have a form where dob is generated using 3 select boxes, 1 for day, month and year. My output needs to be in the form dob=dd-mm-yyyy rather than day=dd, month=mm and year=yyyy.It has been suggested that i do the following:
"On submit button click, use JS to create a hidden input (Q5) in the form and assign its value, then disable the day, month, and year fields so they are not submitted."
Right now this javascript shopping cart works to 1. charge shipping based on the item, 2. the destination country, 3. it combines shipping for a quantity over 1 of the SAME item.Each item has 2 different possible shipping charges. I am trying to get the javascript to check the shopping cart to see what item in the cart has the highest possible shipping charge, charge that amount to that item, and charge the lowest possible shipping charge on all other items in the cart. If item A is purchased alone shipping is $5.00.If purchased with item B, which costs $10.00 to ship alone, the $10.00 is charged for item B and only $3.00 for item A. Because item B had the higher shipping charge at a quantity of one.
I have tried adding various things like me.items[current], item.shipping, me.shipping, this.shipping, shipping_Cost, and other things next to the second && in the part of the script that shows the country. I have also tried adding && if (me.whatever) and && if (item.whatever) and similar things at the beginning of the script next to if (this.country). I have found the parts of the script that pertain to cart items and to updating the shopping cart.The javascript is in 2 parts. One part goes in the item page, which I will post first. The second part goes in an external javascript file which I will post at the bottom. In between there is the part that shows the shopping cart. It isn't part of the javascript.