Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-17-2012, 03:23 AM   PM User | #1
dawg
New Coder

 
Join Date: Nov 2011
Posts: 38
Thanks: 1
Thanked 0 Times in 0 Posts
dawg is an unknown quantity at this point
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 06:11 AM..
dawg is offline   Reply With Quote
Old 08-17-2012, 08:06 AM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
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
AndrewGSW is offline   Reply With Quote
Old 08-17-2012, 01:49 PM   PM User | #3
dawg
New Coder

 
Join Date: Nov 2011
Posts: 38
Thanks: 1
Thanked 0 Times in 0 Posts
dawg is an unknown quantity at this point
Thanks

Works great thanks a million
dawg is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 10:12 PM.


Advertisement
Log in to turn off these ads.