开发者

Best use of Jquery sliders and PHP

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 wha开发者_StackOverflowt's wrong ?

Thanks


Obviously the following is not correct in your CSS selector :

input[type=='hidden']

Replace it by :

input[type='hidden']


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);
            })


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜