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 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2013
    Posts
    28
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Display previous & Next image dynamically using javascript

    Hi to everyone, i am trying to display a 5 image initially

    - When the user clicks "next" i want to display next 5 image from database , vice-versa for "previous" button.i am trying with the following code but i can't able to retrieve the javascript variable to php.
    Code:
    <script type="text/javascript">
      var current=5;
      function moveImage(direction){
       if(direction == "left"){
          loadImage( current - 5 );
       }else{
         loadImage( current + 5 );
       }  
      }
      function loadImage(id)
      { 
        current=id;
      }
    </script>
    <input type="button" name="previous" onClick="moveImage('left')";>
    <input type="button" name="previous" onClick="moveImage('right')";>
    - How to get the javascript value into mysql limit(5,$id),,,

    Please give any suggestion regarding this or any better solution than this to display "previous" & "Next" images dynamically.

  • #2
    Regular Coder
    Join Date
    Aug 2010
    Posts
    974
    Thanks
    19
    Thanked 212 Times in 210 Posts
    Quote Originally Posted by sathish-wd View Post
    Hi to everyone, i am trying to display a 5 image initially

    - When the user clicks "next" i want to display next 5 image from database , vice-versa for "previous" button.i am trying with the following code but i can't able to retrieve the javascript variable to php.
    - How to get the javascript value into mysql limit(5,$id),,,

    Please give any suggestion regarding this or any better solution than this to display "previous" & "Next" images dynamically.
    The most common way would
    be to include a form in your
    page and submit the JavaScript
    value to the php.


  •  

    Tags for this Thread

    Posting Permissions

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