views:

64

answers:

3

Hello there,

I have two questions:

  • What's the best way to send sliders' values to a PHP page ? I'm associating each slider (several per page) with an hidden form so far, but I wonder if there's a "cleaner" way to do this.
  • Related to the 1st question; I've some trouble with the script:

     var score = $(this).slider( "option", "value" );
     $(this).closest("input[type=='hidden']").val(score);
    

It doesn't set the value of the hidden input. Can somebody tells me what's wrong ?

Thanks

A: 

Obviously the following is not correct in your CSS selector :

input[type=='hidden']

Replace it by :

input[type='hidden']
mexique1
A: 

Well, I found something that works, even if it's probably not the cleanest way to do:

I added a class .slideVal to the hidden input and here's the JS code:

            $('.slider').live("mouseup",function(){
                var score = $(this).slider( "option", "value" );
                $(this).closest("tr").find(".slideVal").val(score);
            })
Coronier
A: 

The name of the method closest is misleading.

It returns the first ancestor (parents parents parent etc), that matches the given selector.

You can think of it being equivalent to $(this).parents('.slideVal:first').

Hopefully it's beginning to sink in why your example isn't working!

Matt