JQuery :: The Checkbox Blues/looping Listeners?

Apr 23, 2010

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() {

[code]....

View 16 Replies


ADVERTISEMENT

JQuery :: Setting Up A Bunch Of Listeners With A Looping Structure

Apr 30, 2010

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.

View 10 Replies View Related

Checkbox Event Listeners - Input Type?

May 24, 2009

When catcheck1 is unchecked, I want catcheck9 to uncheck. Why does this not work?
<html><head>
<script type="text/javascript">
// Checkbox event listeners.
function checkboxs() {
document.mapform.catcheck9.checked = false;
}
</script></head><body>
<form action="" name="mapform" id="mapform">
<input type="checkbox" id="catcheck1" name="catcheck9" onclick="checkboxs()" checked />
<input type="checkbox" id="catcheck9" name="catcheck9" checked />
</form></body></html>

View 7 Replies View Related

JQuery :: Superfish Vertical Menu Blues

Apr 12, 2011

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.

View 1 Replies View Related

JQuery :: Change Listeners Without Using HTML?

Aug 2, 2011

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.

View 1 Replies View Related

JQuery :: Can Listeners Work For Html Added Client Side

Sep 15, 2010

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?

View 2 Replies View Related

Event Listeners Won't Use Correct Objects / What To Fix It?

Sep 27, 2011

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?

View 5 Replies View Related

List Of Event Types For Listeners?

Sep 9, 2009

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...

View 4 Replies View Related

Objects & Event Listeners & Scope,

Aug 11, 2004

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...

View 5 Replies View Related

Unable To Remove Event Listeners / Enable This?

Sep 28, 2009

I'm having problems removing the event listeners, they dont seem to be removed

(I am currently only checking for non-ie browsers) code...

View 2 Replies View Related

Handle Objects And The 'this' Keyword When Using Event Listeners?

Feb 24, 2009

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.

[Code]...

View 2 Replies View Related

JavaScript Error Trying To Add Event Listeners Using DOM And AJAX

Oct 29, 2007

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?

View 1 Replies View Related

Can't Set Event Listeners To Multiple Elements Of Same Class

Dec 3, 2009

I'm trying to add event listeners to multiple elements of the same class. The DOM is something like this [code]...

View 5 Replies View Related

Deleting Objects (DOM Notes With Event Listeners Attached)

Jun 29, 2011

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?

View 1 Replies View Related

JQuery :: Select All Checkbox And Execute Each Event Click Checkbox?

Oct 14, 2010

I have a button that selects all the checkbox.

How do I select all checkbox when running the click event of each?

View 2 Replies View Related

JQuery :: Remove Checkbox Value From Xml String With Click Of A Separate Checkbox?

Mar 6, 2011

I have a function that builds an xml string from all selected options in a form like this

function SetServices() {
var services = '<SERVICE><SERVICECD>1KNTK</SERVICECD></SERVICE>';
$(":checked:not([name='ServiceType'], #Standard, #NoneForex, #RTT, #PRN, #BW, #Metrics, #STATUS :input, #EX_AGREEMENTS :input, #final_step :input)").each(function() {

[Code].....

View 4 Replies View Related

JQuery :: Looping Through Array Using Each

Jan 26, 2011

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.

[Code]...

View 2 Replies View Related

JQuery :: For Looping To Reduce Code

Sep 22, 2009

I have 5 buttons all using the same code:
$(".but1").mouseenter(function(){
$(".but1>.launch").animate({ left: "10px"}, 250 );
});
$(".but1").mouseleave(function(){
$(".but1>.launch").animate({ left: "0px"}, 250 );
});
$(".but2").mouseenter(function(){
$(".but2>.launch").animate({ left: "10px"}, 250 );
});
$(".but2").mouseleave(function(){
$(".but2>.launch").animate({ left: "0px"}, 250 );
});
$(".but3").mouseenter(function(){
$(".but3>.launch").animate({ left: "10px"}, 250 );
});
$(".but3").mouseleave(function(){
$(".but3>.launch").animate({ left: "0px"}, 250 );
});
$(".but4").mouseenter(function(){
$(".but4>.launch").animate({ left: "10px"}, 250 );
});
$(".but4").mouseleave(function(){
$(".but4>.launch").animate({ left: "0px"}, 250 );
});
$(".but5").mouseenter(function(){
$(".but5>.launch").animate({ left: "10px"}, 250 );
});
$(".but5").mouseleave(function(){
$(".but5>.launch").animate({ left: "0px"}, 250 );
});
Is there a way to do this in fewer lines of code?

View 12 Replies View Related

JQuery :: Looping Through All The Selected Checkboxes?

Jul 5, 2009

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?

[Code]...

View 1 Replies View Related

JQuery :: Looping Through All Unchecked Checkboxes?

Aug 26, 2009

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.

Method #1
$(".item input:unchecked").each(
function() {
if ($(this).val() > diff) {

[Code]....

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.

View 3 Replies View Related

JQuery :: Looping Through Form Elements?

Jan 7, 2010

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:

[Code]...

View 5 Replies View Related

JQuery :: Looping A Function With Parameters?

Dec 26, 2010

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.

View 4 Replies View Related

JQuery :: Looping Set Of Divs That Are Positioned On Top Of Each Other

Sep 15, 2011

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.

View 1 Replies View Related

JQuery :: Looping Through Arrays - Attribute Value

Sep 13, 2010

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.

View 2 Replies View Related

JQuery :: Looping Through Elements That Have Data() Key?

Jan 11, 2012

I was wondering if there way a way to loop through elements that contain a data key applied by data(). I couldn't find a selector for data keys.

This for instance, I would like to give me the value of 'foo' for where ever it has been applied.

$(document).ready(function() {
$('body').data('foo', 52);
$('head').data('foo', 32);
});

[Code].....

View 3 Replies View Related

JQuery :: Looping Thru Hidden Fields By ID?

Jun 25, 2011

I want to loop thru all the hidden fields on the page, that have an ID which starts with "general_" and ends in "_10". Eg IDs:

id = "general_name_10"
id = "general_link_10"
id = "general_price_10"

How can I do such a loop in jQuery?

View 18 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved