473,396 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

a possible global function from local

imarkdesigns
hello to all masters,

just wrote a code from my pre-made javascript slider though i have to add function on the same settings with play/pause and stop button.

here's the current site: Slider


here's my Play and Stop code link
Expand|Select|Wrap|Line Numbers
  1. <span><a href="#" id="play" onclick="speed('500')">Play</a>  <a href="#" id="stop" onclick="speed('500000')">Stop</a></span>
  2.  
and here's the code for value that i want to overwrite when i press Play or Stop button.

Expand|Select|Wrap|Line Numbers
  1. //Play button: 500;
  2. //Stop button: 5000000;
  3. var speed = 1000; //default speed
  4.  
  5. var slider={
  6.  num:-1,
  7.  cur:0,
  8.  cr:[],
  9.  al:null,
  10.  at:10*speed, //<-- code that will apply from buttons.
  11.  ar:true,
  12. }
  13.  

advance thanks for the great suggestion and idea.
Jun 22 '10 #1
12 1651
johny10151981
1,059 1GB
Expand|Select|Wrap|Line Numbers
  1. <a href="#" id="play" onclick="speed('500')">Play</a> 
please take a look in the above code. On onclick action you called a function name speed, i want to know is there any function name speed. In my quick search i have not got any function name speed. In your script you have declared a variable name speed and assigned 1000. But its not a function.

speed is not a function and it not doing anything, if you want do something like that :
if a user press the play link then and and action will happen.
Then declare a function that will actually do action, the "what ever it is". and call the function from onClick event.

Best Regards
johny
Jun 22 '10 #2
ah yes sir actually i removed the previous code since i already misunderstood the correct and proper coding of the function in where i get the codes over internet. however, the speed is still my current selected variable for the value of buttons when it clicked.
Jun 22 '10 #3
johny10151981
1,059 1GB
Try to understand the demo below
Expand|Select|Wrap|Line Numbers
  1. <SCRIPT>
  2.  
  3.  
  4.    //Play button: 500;
  5.    //Stop button: 5000000;
  6.    var speed = 1000; //default speed
  7.    var slider={
  8.    num:-1,
  9.    cur:0,
  10.    cr:[],
  11.    al:null,
  12.    at:10*speed, //<-- code that will apply from buttons.
  13.    ar:true,
  14.   }
  15.  
  16.   function set_speed(value)
  17.   {
  18.    speed=value;
  19.   }
  20.  
  21. </SCRIPT>
  22.  
  23.  
  24.  
  25.   <span><a href="#" id="play" onclick="set_speed('500')">Play</a>  <a href="#" id="stop" onclick="set_speed('500000')">Stop</a></span>
  26.  
Simplest code, try to understand, it may help you
Jun 22 '10 #4
ok sir, thanks for the idea. i will try this right away.
Jun 22 '10 #5
@johny10151981

hmmm.. still no luck for the actual codes. :(

anyway, here's the full codes from the javascript and html


HTML
Expand|Select|Wrap|Line Numbers
  1.         <div id="slide-holder">
  2.           <div id="slide-runner">
  3.             <a href="page.php?name=financial"><img src="assets/media/ajax/frame1.png" width="1000" height="310" id="slide-img-1" class="slide" alt=""></a>
  4.             <a href="page.php?name=plan"><img src="assets/media/ajax/frame2.png" width="1000" height="310" id="slide-img-2" class="slide" alt=""></a>
  5.             <a href="page.php?name=affinity"><img src="assets/media/ajax/frame3.png" width="1000" height="310" id="slide-img-3" class="slide" alt=""></a>
  6.             <div id="slide-controls">
  7.                 <a href="#" id="play" onclick="set_speed('10')">Play</a>  <a href="#" id="stop" onclick="set_speed('500000')">Stop</a>
  8.               <p id="slide-nav"></p>
  9.             </div>
  10.           </div>
  11.         </div>            
  12.  
JavaScript
Expand|Select|Wrap|Line Numbers
  1. //Default Value
  2. var speed = 1000; //default speed
  3.  
  4. //Slider
  5. var slider={
  6.  num:-1,
  7.  cur:0,
  8.  cr:[],
  9.  al:null,
  10.  at:10*speed, //Current Value is 1000
  11.  ar:true,
  12.  init:function(){
  13.   if(!slider.data || !slider.data.length)
  14.    return false;
  15.  
  16.   var d=slider.data;
  17.   slider.num=d.length;
  18.   var pos=Math.floor(Math.random()*1);//slider.num);
  19.   for(var i=0;i<slider.num;i++){
  20.    $('#'+d[i].id).css({bottom:((i-pos)*310)});
  21.    $('#slide-nav').append('<a id="slide-link-'+i+'" href="#" onclick="slider.slide('+i+');return false;" onfocus="this.blur();">'+(i+1)+'</a>');
  22.   }
  23.  
  24.   $('img,div#slide-controls',$('div#slide-holder')).fadeIn();
  25.   slider.text(d[pos]);
  26.   slider.on(pos);
  27.   slider.cur=pos;
  28.   window.setTimeout('slider.auto();',slider.at);
  29.  },
  30.  auto:function(){
  31.   if(!slider.ar)
  32.    return false;
  33.  
  34.   var next=slider.cur+1;
  35.   if(next>=slider.num) next=0;
  36.   slider.slide(next);
  37.  },
  38.  slide:function(pos){
  39.   if(pos<0 || pos>=slider.num || pos==slider.cur)
  40.    return;
  41.  
  42.   window.clearTimeout(slider.al);
  43.   slider.al=window.setTimeout('slider.auto();',slider.at);
  44.  
  45.   var d=slider.data;
  46.   for(var i=0;i<slider.num;i++)
  47.    $('#'+d[i].id).stop().animate({bottom:((i-pos)*310)},1000);
  48.  
  49.   slider.on(pos);
  50.   slider.text(d[pos]);
  51.   slider.cur=pos;
  52.  },
  53.  on:function(pos){
  54.   $('#slide-nav a').removeClass('on');
  55.   $('#slide-nav a#slide-link-'+pos).addClass('on');
  56.  },
  57.  text:function(di){
  58.   slider.cr['a']=di.client;
  59.   slider.cr['b']=di.desc;
  60.   slider.ticker('#slide-client span',di.client,0,'a');
  61.   slider.ticker('#slide-desc',di.desc,0,'b');
  62.  },
  63.  ticker:function(el,text,pos,unique){
  64.   if(slider.cr[unique]!=text)
  65.    return false;
  66.  
  67.   ctext=text.substring(0,pos)+(pos%2?'-':'_');
  68.   $(el).html(ctext);
  69.  
  70.   if(pos==text.length)
  71.    $(el).html(text);
  72.   else
  73.    window.setTimeout('slider.ticker("'+el+'","'+text+'",'+(pos+1)+',"'+unique+'");',30);
  74.  }
  75. };
  76.  
  77. //Button to change the Speed Value
  78. function set_speed(value){
  79.  speed = value;
  80. };
  81.  
@johny10151981,
i already included your current given codes here.
i tried to lowest the value of play so i can check if it is changing the speed value of 1000 inside the javascript file. but it isn't changing.. this is my main problem. @_@ i have been searching through the net for the guidelines but i am almost near to get frustrated to find a correct codes.
Jun 22 '10 #6
johny10151981
1,059 1GB
@imarkdesigns
Can you please send the whole page, or page link where i can directly access
Jun 22 '10 #7
johny10151981
1,059 1GB
My bad,
You took the code its true but you didnt modify properly.
Expand|Select|Wrap|Line Numbers
  1. var slider={
  2.   num:-1,
  3.   cur:0,
  4.   cr:[],
  5.   al:null,
  6.   at:10*speed, //Current Value is 1000
  7.   ar:true,
  8.   init:function(){
  9.   if(!slider.data || !slider.data.length)
  10.   return false;
  11.  
  12.   var d=slider.data;
  13.   slider.num=d.length;
  14.   var pos=Math.floor(Math.random()*1);//slider.num);
  15.   for(var i=0;i<slider.num;i++){
  16.   $('#'+d[i].id).css({bottom:((i-pos)*310)});
  17.   $('#slide-nav').append('<a id="slide-link-'+i+'" href="#" onclick="slider.slide('+i+');return false;" onfocus="this.blur();">'+(i+1)+'</a>');
  18.   }
  19.  
take a look at the above variable.
you are setting speed variable. but it is not effecting the code at all. Because you set
at:10*speed, //Current Value is 1000 in global
you are setting speed but it is not effecting your object. Do some more action in the set_speed function so that the speed value work
Jun 22 '10 #8
yeah that was my current problem on how to code the button functionally inside the JavaScript. :(
Jun 22 '10 #10
johny10151981
1,059 1GB
@imarkdesigns
Well here I am stuck. This does not look like Javascript to me. I only can tell you what you are missing. Dont know the codes. Sorry mate hope some one else can help you with code.
Really sorry
Jun 22 '10 #11
yeah.. i understand that. though the script is already made for the current slider. that is how i just wanted to check if i can still add some navigation through the codes. honestly, took me 7 hours today just to figure it out this Ajax slider.

anyway, thanks for the time and effort sir i appreciate it.
Jun 22 '10 #12
up for the topic...
Jun 22 '10 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Dalan | last post by:
I need some assistance or advise in composing code for a global function module or a related one for populating values in text boxes on reports and forms with a name, actually several different...
3
by: RA | last post by:
Hi Is it possible to have a global function that I can access from all the aspx web forms? This function basically will reset the Cache object to delete all the stored fields within it. ...
4
by: Simon Harris | last post by:
Hi All, I'm new to ASP.Net, so be gentle! (Plenty of 'classic' ASP experience), just one question... - Am I correct in thinking that global functions are stored in ASCX files? Thanks! ...
2
by: Henry | last post by:
Hi guys, I want to write some global functions which can be called from different asp.net page. In Visual Basic, there is a global module which allow me to do that. In Visual Basic .net, I...
0
by: ss | last post by:
i read a few posts about global function access. well i am not interested in global functions. rather, i am seeking for a way to may my call in ASPX pages but not the code behind. for example:...
1
by: awburns | last post by:
Hi, A friend of mine has written a C# Assembly to get some data. To do so, though, involves creating an object ( a 'Login' object, containing the user's credentials) and then running a "login()"...
4
by: Ming | last post by:
Very frequently, I need to use codes like this to see output clearly: $a=print_r($var,true); echo "<pre>$a</pre>"; How can convert this piece of code to a global function (for example:...
3
by: George2 | last post by:
Hello everyone, 1. Returning non-const reference to function local object is not correct. But is it correct to return const reference to function local object? 2. If in (1), it is correct...
3
by: anoop.kn | last post by:
Is there anyway to access Global Function Pointer from its name ? I want to call the function at runtime during a script execution. PS: eval() works, I looking for a more efficient way of doing the...
2
by: Anish Chapagain | last post by:
Hi, I have Structure in C, program and the structure is being used with various function inside C coding but am getting undefined referenced to global method and few of them too uses the sturct...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.