Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > jQuery and XPath

Reply
Thread Tools

jQuery and XPath

 
 
Gale
Guest
Posts: n/a
 
      06-01-2006
I'm working on something in jQuery with XPath

What I want to do is: if checkbox is checked, set background color od
label that contain input(checkbox) to red

I have this code:
$("label[input[@checked]]").css("background", "red");

but it doesn't working because of nested brackets [[ ]] and it freeze
the browser
In Xpath documentation say it can be used

any sugestions?

 
Reply With Quote
 
 
 
 
VK
Guest
Posts: n/a
 
      06-02-2006

Gale wrote:
> I'm working on something in jQuery with XPath


So how or anyhow is that related to JavaScript/JScript? Neither of both
atop are connected with it.

For JavaScript solution ask here (will be glad to help), for XPath
solution ask at <comp.text.xml>, for jQuery plugin ask at some Eclipse
forum.

 
Reply With Quote
 
 
 
 
Abba.Bryant@gmail.com
Guest
Posts: n/a
 
      06-02-2006

VK wrote:
> Gale wrote:
> > I'm working on something in jQuery with XPath

>
> So how or anyhow is that related to JavaScript/JScript? Neither of both
> atop are connected with it.
>
> For JavaScript solution ask here (will be glad to help), for XPath
> solution ask at <comp.text.xml>, for jQuery plugin ask at some Eclipse
> forum.


*OR* Before you run your mouth off about something you have no clue
about - being in this case that the mentioned JQuery is a JAVASCRIPT
LIBRARY supporting css / xpath / expressions to apply behaviors to dom
elements.

To the original poster. Drop John Resig an Email from the form on the
jquery page. I have had similiar issues with the xpath selectors. Some
of the custom expressions might be useful to you though.

 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      06-03-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> *OR* Before you run your mouth off about something you have no clue
> about - being in this case that the mentioned JQuery is a JAVASCRIPT
> LIBRARY supporting css / xpath / expressions to apply behaviors to dom
> elements.


Or really? Which one of them? There are at least 3 plugin/library
called jQuery (variant JQuery) matching the OP's description. The name
is too "sound" for a bizword so all kind of wannabes used it for
software of all kinds of quality. Presuming for a minite it is not
about Eclipse but about <http://jquery.com/> (just one of numerous
variants). In such case I'm sure OP will be glafle helped at
<http://jquery.com/discuss/>

If OP wanted a JavaScript help, then the traversal should go in the
normal way, not upside down as (I presume) suggested by the "logic" of
the library. Namely on a standard-compliant page (thus all labels have
"for" attribute) one retrieves all labels for a given range and /then/
accesses the attached elements:

var labels = document.getElementsByTagName('LABEL');
var obj = null;
for (var i=0; i<labels.length; i++) {
obj = document.getElementById(labels[i].htmlFor);
if (obj.checked) {
labels[i].style.backgroundColor = 'red';
}
}

This is about JavaScript; for jQuery/JQuery/jquery use relevant URL's.

 
Reply With Quote
 
Gale
Guest
Posts: n/a
 
      06-03-2006
VK wrote:
> (E-Mail Removed) wrote:
>> *OR* Before you run your mouth off about something you have no clue
>> about - being in this case that the mentioned JQuery is a JAVASCRIPT
>> LIBRARY supporting css / xpath / expressions to apply behaviors to dom
>> elements.

>
> Or really? Which one of them? There are at least 3 plugin/library
> called jQuery (variant JQuery) matching the OP's description. The name
> is too "sound" for a bizword so all kind of wannabes used it for
> software of all kinds of quality. Presuming for a minite it is not
> about Eclipse but about <http://jquery.com/> (just one of numerous
> variants). In such case I'm sure OP will be glafle helped at
> <http://jquery.com/discuss/>
>
> If OP wanted a JavaScript help, then the traversal should go in the
> normal way, not upside down as (I presume) suggested by the "logic" of
> the library. Namely on a standard-compliant page (thus all labels have
> "for" attribute) one retrieves all labels for a given range and /then/
> accesses the attached elements:
>
> var labels = document.getElementsByTagName('LABEL');
> var obj = null;
> for (var i=0; i<labels.length; i++) {
> obj = document.getElementById(labels[i].htmlFor);
> if (obj.checked) {
> labels[i].style.backgroundColor = 'red';
> }
> }
>
> This is about JavaScript; for jQuery/JQuery/jquery use relevant URL's.
>


I want to do it with XPath !!!
 
Reply With Quote
 
Gale
Guest
Posts: n/a
 
      06-03-2006
(E-Mail Removed) wrote:
> VK wrote:
>
> To the original poster. Drop John Resig an Email from the form on the
> jquery page. I have had similiar issues with the xpath selectors. Some
> of the custom expressions might be useful to you though.
>


Thank you I will try that!
 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      06-03-2006
Gale wrote:
> I want to do it with XPath !!!


You cannot do it with XPath: XPath is a language to traverse nodes in
XML document during the transformation (look for XSLT). On the
mentioned stage JavaScript is useless as the resulting document doesn't
exist yet. Never repeat someone bogus ads just because it sounds cool.
You mean to say "I want to do it using pseudo-XPath syntax supported in
the used JavaScript library". As internally these "XPath commands" is
nothing but plain strings parsed and used by JavaScript functions, I
presume some string parsing bug. Follow the advise of other poster -
simply be aware that you are not using XPath - you are using XPath-like
syntax. That makes a difference.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft expanding it use of jQuery & involvement with jQuery lorlarz Javascript 6 03-25-2010 10:14 PM
jQuery Query about comparing jQuery references Aaron Gray Javascript 20 07-27-2008 01:53 PM
"Memory leak" in javax.xml.xpath.XPath Marvin_123456 Java 4 07-29-2005 03:49 PM
XPath that does not include other XPath Anna XML 0 07-31-2003 07:55 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM



Advertisments