How To Add Jquery Value To DB When Function Ends?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
jbh
Forum Commoner
Posts: 89
Joined: Tue Dec 05, 2006 7:01 pm

How To Add Jquery Value To DB When Function Ends?

Post by jbh »

Hey. I am working on figuring out how the Jquery UI Slider works. For reference:

http://docs.jquery.com/UI/API/1.7.2/Slider

To be more clear, I am trying to learn how to manipulate it so the value, once the slider has stopped, are entered into mysql. Below is
the working code of my slider which, for now, is used as a rating system. The bold part
is what displays the value after the slider is in use. All I want to do is add that to mysql via ajax.

Do I just call an ajax function and use var= ... to create the variable and send it? Do I need special ajax
code to say "The slider has stopped, NOW insert it" ? This is where I am confused. Ty

Code: Select all

   <script type="text/javascript">
    $(function() {
        $("#slider").slider({
            value:5,
            min: 0,
            max: 5,
            step: 1,
            slide: function(event, ui) {
[b]                 $("#amount").val('' + ui.value + ' Stars');[/b]
            }
        });
        $("#amount").val('' + $("#slider").slider("value") + ' Stars');
    });
    </script>
Actually, I wonder if something like:
$.post("http://site.com", {queryString: ""+inputString+""}
would work? If so, would I be able to create a var for the value or just pass it to a hidden field and then submit based on that, if I call the field inputString?

Thanks.
jbh
Forum Commoner
Posts: 89
Joined: Tue Dec 05, 2006 7:01 pm

Re: How To Add Jquery Value To DB When Function Ends?

Post by jbh »

One thing to mention. I do have a text field that displays, dynamically, the value

<input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;" / name="test">

I guess my question is how do I use the built in 'stop' function to autosubmit/ajax post? I know HOW to ajax post,
but syntax wise I am still not sure how to set it up. In the meantime I will keep searching, but I had to ask in case
anybody has done this before.

TY. Should I find the solution I will post it here in detail.
Post Reply