Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 6th, 2012  |  syntax: None  |  size: 1.21 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How do I change the value when I click on the right arrow?
  2. $(function(){
  3.     var room = ['1-visiting office', '2-', '3-'];      
  4.     $('#text_holder').val(room[0]);
  5.  
  6.     $("#rightarrow").click(function(){      
  7.         $('#text_holder').val(room[next]);      
  8.     });
  9. });
  10.        
  11. <input id="text_holder" name="text_holder"/>
  12. <img src="dev/images/rightarrow.jpg" id="rightarrow" />
  13.        
  14. $(function(){
  15.     var room = ['1-visiting office', '2-', '3-'];
  16.     $('#text_holder').val(room[0]);
  17.  
  18.     $("#rightarrow").data('counter', 0).click(function(){
  19.         var counter = $(this).data('counter')+1;
  20.         $('#text_holder').val(room[counter]);
  21.         $(this).data('counter', counter);
  22.     });
  23. });
  24.        
  25. $(function(){
  26.     var room = ['1-visiting office', '2-', '3-'];
  27.     $('#text_holder').val(room[0]);
  28.  
  29.     $("#rightarrow").data('counter', 0).click(function(){
  30.         var counter = ($(this).data('counter')+1) % room.length;
  31.         $('#text_holder').val(room[counter]);
  32.         $(this).data('counter', counter);
  33.     });
  34. });
  35.        
  36. $(function(){
  37.     var room = ['1-visiting office', '2-', '3-'];      
  38.     var counter = 0;
  39.     $("#rightarrow").click(function(){      
  40.         $('#text_holder').val(room[counter++]);    
  41.     }).click();
  42. });