I have a quandary of sorts here dealing with a list of checkboxes and the hiding/showing of a few divs associated with the checkbox selection. Here's basically what I need to do: Hide the lower div if no checkbox is selected. If any one of the first 6 checkboxes are selected, and NOT any of the remaining 6, then show the div. If at any time during selection one of the remaining 6 checkboxes are selected, then hide the associated div. Note this code doesn't really do much. I'm still trying to architect a solution that's best.
var aThroughf = false;
var gThroughl = false;
$('[name="'+q2030.name+'"]')).live('click', function() {
I'm trying to come up with a better architecture for dealing with multiple listeners in a multi-page questionnaire. Here's the general structure I'm looking to implement:
1. Set up CSS for animation
2. Look for preconditions
3. Initialize listener
4. Execute animation
Some issues to consider:
1. Some questions have dependencies that show or hide depending on what is selected in a parent question.
2. Needs to be IE 6 compatible.
3. It should be simple enough so that all you need to do is add a new question to a JSON object, which is what I have set up right now.
Some code (the looping structure that reads each question):
var newQ = eval(q); $.each(newQ, function () { // 1 - Setting CSS for each listener $(this.css).css({'width': '1500px', 'float': 'left', 'clear':'both'});
[Code].....
The problem here is that when I do a console.dir on $.each(this.value.length), it counts each character, as opposed to counting the number of elements in the array. Should I be doing an eval on q? Why or why not? If I could get this up and running, it would make my life 100x easier, as there are hundreds of questions, and I'd want to make this all data driven.
I'm using the Superfish vertical menu to develop an online book. My vertical menu which consists of chapters and sections place on the side of my page, and is long enough to show all of the main items. However, as the chapters get lower in the page, the submenu items (my section names) get cutoff (there's not enough room to show all subitems for the final 2 chapters). So, I guess I have 2 questions:
1) Is there some sort of option to tell Superfish to realize "Hey, not enough room for the menu, so I need to move the submenu up higher" and if not
2) Could someone give me some direction as to how I might be able to move "up" a few of my submenus by diving into the code? In other words, instead of the first item in my submenu visually matching up with the main option, have the 3rd or 4th visually matchup, thereby giving me the extra space needed when close to the bottom of the page.
I know this isn't a jQuery question per se, but maybe there is an easier way to do this is jQuery than in javascript?
<script>
I was wondering if there is a better way to accomplish the above? Rather than directly changing the innerHTML of the element is it possible to add a onclick listener (or another javascript listener) to the element in a more direct way without having to go through the html.
I have taken over from a developer who has used javascript to add additional text input boxes to a form so there is no limit to the number of input boxes there can be. I have got a jquery autocomplete function that works fine if the input box is added by the server but the listener doesnt fire when the text box is added client side. As with all things this is part of a much bigger project and I only want to change the smallest possible part (add autocomplete to this text input box) MY QUESTION: is it even possible fo ra jquery listener to fire when the input box has been written client side after the page has loaded? Is there a way to "refresh" a listenerto find the new tag that have been added?
I feel like I must be missing something simple but I can't put my finger on it...
I'm moderately new to JS (programmed in other languages though) and am working on a Google Maps project.
This piece of code should show an alert of the region's name when a map polygon is clicked. Instead, no matter what polygon is clicked, it only does the name for the LAST iterated placemark. code...
What am I missing? What would be a better way of handling this?
Does anyone know where I can find a complete list of DOM/DHTML event types documented?
I'm trying to learn more about advanced event handling in JavaScript and I'd like to find lists of event types that I can attach/add event listeners to. I've been searching around and I've found a few resources, but nothing that seems complete.code...
Here's the situation: I have a javascript object for controlling a custom DHTML scrollbar. So that I can use more than one on a page, the event listeners need to be passed a reference to the particular instance of the object that each needs to connect to, but as I discovered the hard way, inside an event listener, 'this' returns a reference to the DOM object throwing the event, rather than to the JS object. Short of coming up with a linked list of different objects and having the event handler search through it for the right object when an event is generated, then writing a reference to that object to some global variable, is there any convenient way to tie this together? I hope I've made myself clear enough...
So I know all about the caviats of the 'this' keyword when calling object functions from event listeners:
Code: var foo = {bar: true, zoo: function() { return this.bar; }}; foo.zoo(); > true a = foo.zoo; a(); >
And I know that I can get around this by using an anonymous function so that 'this' is preserved in it's original context:
[Code]...
But then someone pointed out this article on memory leaks when using anonymous functions to call object methods because the anonymous function gets access to ALL variables in the enclosing environment and my not be properly disposed of by the garbage collector [URL] So that lead me to think about using a "3rd-person" approach to referencing object properties from within object methods.
I have PHP file called file1.php with an empty <div></div> in the middle. I've added a 'load' event listener so that on page load, it calls an AJAX function that calls file2.php. file2.php creates a table and loads it into the <div></div> in file1.php.
file2.php has <a> tags in it's <th> columns and I wish to trap when a user clicks on the column heading. The old way was to use the onclick() method but I'd rather use event listeners.
Here's my problem. I am getting "obj has no properties" when trying to add those listeners. I *think* it is because the code in file2.php isn't part of the original DOM tree for file1.php. So how can I use event listeners instead of onlclick()? I know I can add top the DOM by creating elements and appending them but that adds to the HTML code and my code is already in place via the AJAX call. What to do...? DO I just use the old passe onclick() method?
I am creating JS objects that have some properties that contain DOM nodes, and some of these DOM nodes have event listeners attached to them. When I delete such objects, do I first need to remove the event listeners attached to some of the DOM nodes? And do I need to use removeChild on the DOM nodes that are properties of the object? Or does JavaScript take care of all that?
If got problem with .each looping in jquery. im am trying to make a animation with jQuery. And i want to switch between three quotes of the array. and now it only works for the first quote of the array.
This is what i have. It does not correctly add two values when two checkboxes are checked. It should add up to 160 but it adds up to 20 instead! any ideas?
I have a function which is executed whenever someone clicks a checkbox on the page. There are lots of checkboxes on the page. I want the function to be performed on only the unchecked boxes. I've tried this two ways, neither of which has worked. Here are the two methods I've tried.
Where diff is an integer and the values of the checkboxes are all integers. The problem is the function ends up getting run on all checkboxes, even boxes that have been checked.
I'm relatively new to JavaScript. I would like to loop through all the elements within a form and grab their values and what type of input they are. So far I came up with:
I have a problem with a function i created. I want an image to move from a to b and then start from a again. Without parameters this works really fine, but now that I have got more images I use parameters but I have no clue how to call the funtion again.
[Code]...
I tried to replace show(100,flo) with show(100,flo(zahl,r_g)) but then the divs only move from a to b but even will not come back to a again. I think the solution should be pretty simple but i cant figure it out.
I'm having an issue with looping a set of divs that are positioned on top of each other. When a link is clicked, the second div should fade in as the top div fades out, which coincides with another div changing background colour.As you'll notice, when the link is clicked for a third time, it loops back to the beginning by using the rel tag to keep track of what div is showing. The problem is that when it loops to the beginning the animation is not in sync with the second div changing colour.The code for all three is exactly the same and it doesn't matter how many coloured divs you have, it's always the last one fading out that causes the issue. The '#second' colour change fires after the box changes, not synchronised like the previous clicks.This is a basic example that I'm using on a site elsewhere so the concept of the second div fading in and then the first fading out is important - I can't switch so the first fades out then the second fades in.
I have a list of inputs <div id="divID"> <input title="foo" type="text"> <input title="bar" type="text"> </div>
Then I'm trying to use jQuery to cycle through each input and ascribe ".attr("value") to each respective <input>. So far I've been using something along these lines: var input = $('#divID input') input.each(function(i) { var title = input[i].attr("title"); input[i].attr("value", title); } If I remove the "[i]", it fills in every box with the title of the first <input>. If I leave it there, it fills in the first input, and then upon looping, says input[i].attr is not a function. So, if I type console.log(input[1]), firebug returns the correct <input> tag, but as soon as I add the .attr(); function, it blows up.