The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 17, 2019, 12:03:55 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: jQuery assistance needed  (Read 2167 times)
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« on: June 29, 2010, 08:28:57 PM »

I know I must be being a complete idiot here, but I'm having trouble with jQuery and something I need to do.

I have dynamic webapps that will build large tables of data that I need to get extracted to XML and sent up to my server via Ajax.

The first step is to simply get a wrapped set of all the tables that are containers for the information inside. And with that set, I fire off an iterator to get the innards. Each of the tables that I'll encounter can be completely different, so I need to further query the individual table that I'm currently sitting on in the iterator. Example:

var tables = $('.ruleTemplate').each(function() {

}

... so now inside the function() I can use $(this) to get access to the individual table. What I want to do is ask the (this) dom element for all TR elements inside of it, then for each row I need to ask for all selects and inputs.

In sort of a pseudo-BASIC combined with jQuery what I'm trying to do would look like this:
Code:
tables = $('TABLE');
for i = 0 to tables.length
rows = tables[i].$('TR') // note here that I am jQuerying for rows ONLY from the (nth) table
for j = 0 to rows.length
selects = rows[j].$('SELECT') // same here ... looking for selects that are children of the current row...
inputs = rows[j].$('INPUT')

// Do stuff here now with the selects and inputs I've grabbed

next j
next i

I guess another way of saying this is that I'd like to do a jQuery search of a chunk of the DOM that is NOT the whole page ... I'd like to start from an element of my choosing. In Javascript I can say someElement.getElementsByTagName('TR') and it will search with someElement as the root and go deeper - it will not return everything from the whole page.

Probably something enormously simple and I'm missing it, appreciate any help  Undecided
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: June 29, 2010, 08:41:02 PM »

Nevermind - I found it. Context parameter in the jQuery function is an optional.

EG: var selects = $('SELECT', document.getElementById('targetElement'));

would return all selects within the dom element with an id of targetElement. I knew all I'd have to do is post here and I'd get the answer  ROFLMAO
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #2 on: June 29, 2010, 08:52:29 PM »

glad I could help.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!