www.webdeveloper.com
Results 1 to 4 of 4

Thread: how to display up and down arrow on buttom

  1. #1
    Join Date
    Jan 2006
    Posts
    10

    how to display up and down arrow on buttom

    hi, all

    I got table out of databse and display bor asc or desc order, how do I use javascript to display the up and down arrow key on the side of buttom to show the asc or desc order?

    thx

  2. #2
    Join Date
    Dec 2005
    Location
    Queen Creek, AZ
    Posts
    1,564
    if you just want to display the images for up and down arrows, find some nice images you want to use, then on the button tag, add style="background: url(upimage.gif)" where upimage.gif is actually the name of the image for the up arrow. Do the same for the down button. Mkae sute the button has a value of "" or no value declaration at all.
    Design first! Code later!

  3. #3
    Join Date
    Jan 2006
    Posts
    10
    is it possible that both up and down are on the same button?

    right now I am doing the table could be sort by item name or price, those two button would be submit hidden field value to servlet, so at the beginning, the button would be "item" and "price", if I click item then servlet will sent back the table sort by item's name asc, so it would be up arrow on the side of item button, it is possible to be done without grid? thx

  4. #4
    Join Date
    Dec 2005
    Location
    Queen Creek, AZ
    Posts
    1,564
    sure, you can just use 1 button as long as you can detect what way the servlet returned the recordset.

    create avraible called servReturn and when the servlet returns the sort 'asc', set the variable to 'asc' and likewise for the 'dec'.
    then at the end of your servlet processing script, just add something like:

    if(servReturn == 'asc'){
    document.getElementById('btnSort').setAttribute('style','background:url(xxx.gif)');
    }else{
    document.getElementById('btnSort').setAttribute('style','background:url(yyy.gif)');
    }

    where your button is called btnSort, and your images are xxx.gif for up arrow and yyy.gif for down arrow.

    or simpler: if you call the up arrow image asc.gif and the down image dec.gif, you can just use this line at the end of the servlet processing script:

    document.getElementById('btnSort').setAttribute('style', servReturn + '.gif');

    give that a go, should work, although I haven't tested it
    Design first! Code later!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles