Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2011
    Posts
    61
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Deleting a variable

    So I have a slider, I want to call a function to control speed, now it works if I pick a higher number, but it won't delete the previous variable and continues to call the function over and over (highlighted in red).

    <code>
    $(function() {
    $( "#slider" ).slider({
    orientation: "horizontal",
    range: 1000,
    max: 20000,
    min:1000,
    value: 5000,
    slide: function(event, ui) {
    // myInt=setInterval(runPHPScript, (((ui.value/1000).toFixed(0))*1000));
    $("#slider_value").val((ui.value/1000).toFixed(0));
    }
    ,
    stop: function(event, ui) {
    delete myInt;
    var myInt = setInterval(runPHPScript, ui.value);

    },
    change: function(event, ui) {
    myInt=setInterval(runPHPScript, (((ui.value/1000).toFixed(0))*1000));
    $("#slider_value").val((ui.value/1000).toFixed(0));
    }
    });</code>
    Last edited by dawg; 08-17-2012 at 07:11 AM.

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Not exactly sure what your code is attempting, but assume you're looking for:

    Code:
    clearInterval(myInt);
    // rather than delete myInt;
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #3
    New Coder
    Join Date
    Nov 2011
    Posts
    61
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thanks

    Works great thanks a million


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •