1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Problem with keyboard control

Discussion in 'jQuery' started by mark103, Sep 26, 2013.

  1. #1
    Hi guys,

    I'm working on the div class of blocks to control them using the keyboard up and down arrow buttons. I have the list of blocks where 7 of them are showing while the other blocks are hiding. I have text of blocks from block 1 to block 17. When I press on the down arrow button from block 1 to block 17, the blocks will move up using 'rowheight' which it looks good to go, but there is a problem. When I press on the up arrow button and the down arrow button after the block 7, the blocks supposed to stay where they are but it will move up when the yellow block is on the block 8, block 9, block 10, block 11, block 12, block 13, block 14, block 15, block 16 and block 17.


    I think the problem are somewhere in this code:

      if (event.keyCode == 40)
      {  //down
      if(current_col < totalrowcount && current_row == 1)
      {
      if(current_col >= displayrowcount)
      {
      var currentrowtop = $(".mainWrap div.row:first-child").css( "margin-top");
      currentrowtop = parseInt(currentrowtop)-rowheight;
      var rowtop = currentrowtop+="px";
      $(".mainWrap div.row:first-child").css( "margin-top", rowtop );
      }
      current_col++;
      }
      }
    PHP:

    In this case, when I press on the down arrow button from block 1 to block 7 and if I press on the up arrow button, the blocks will not move up where it stays on. When I press on the down arrow button after the block 7, if I press on the up arrow button and then the down arrow button, the blocks will move up. The same things that goes for other blocks. I want the blocks to move up only when I'm after the end of the block where the blocks are hiding, e.g.: I'm on the block 7 while the other blocks after the block 7 are hiding so I can move them up. I don't want to move the blocks up when I'm not the end of the block.

    Does anyone know how I can block the blocks from move up when I'm not after the end of the block while the other blocks are hiding?

    Here's my example site if you need to take a look: http://testbox.elementfx.com/blocks.php
     
    mark103, Sep 26, 2013 IP
  2. mark103

    mark103 Active Member

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #2
    Does anyone know how I can block the blocks from move up when I'm on the middle of the block while the other blocks are hiding?
     
    mark103, Sep 29, 2013 IP