943,832 Members | Top Members by Rank

Ad:
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Oct 2nd, 2008
0

Re: Multiple select autoscroll to last item

Anyone has the time to look at this problem, its just not solved right now.

Thanks in advance
Reputation Points: 17
Solved Threads: 2
Junior Poster in Training
kvdd is offline Offline
55 posts
since Jun 2008
Oct 2nd, 2008
0

Re: Multiple select autoscroll to last item

Hi, I've been busy with many things that have been keeping me away from the computer the last several weeks ... sorry for the lag time in getting back to this.

It's actually pretty easy to modify this script to act on specific form-element fields instead of on the forms.

Try this:
javascript Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4.  
  5. window.onload = function () {
  6. // Since we only need to auto-scroll the select elements
  7. // after the page has loaded ...
  8. // list auto-scroll selects by id
  9. select_list = new Array( 'test_one', 'test_too' );
  10. scroll_selected( select_list );
  11. };
  12.  
  13. function scroll_selected ( selects ) {
  14. OUTER: for ( var i = 0; i < selects.length; i ++ ) {
  15. var select = document.getElementById(selects[i]);
  16. var opts = select.getElementsByTagName('option');
  17. for ( var j = opts.length -1; j > 0; --j ) {
  18. if ( opts.item(j).selected == true ) {
  19. select.scrollTop = j * opts.item(j).offsetHeight;
  20. opts.item(j).selected = true;
  21. continue OUTER;
  22. }
  23. }
  24. }
  25. }
  26. </script>
  27. </head>
  28. <body style="padding:60px">
  29. <form>
  30. <p>Select Multiple:<br />
  31. <select id="test_one" multiple size="3">
  32. <option name="one" value="1">one</option>
  33. <option name="two" value="2">two</option>
  34. <option name="three" value="3" selected>three</option>
  35. <option name="four" value="4">four</option>
  36. <option name="five" value="5">five</option>
  37. <option name="six" value="6" selected>six</option>
  38. </select>
  39. <p>Select One:<br />
  40. <select size="3">
  41. <option name="one" value="1" selected>one</option>
  42. <option name="two" value="2">two</option>
  43. <option name="three" value="3">three</option>
  44. <option name="four" value="4">four</option>
  45. <option name="five" value="5">five</option>
  46. <option name="six" value="6">six</option>
  47. </select>
  48. <p>Select Multiple:<br />
  49. <select id="test_too" multiple size="3">
  50. <option name="one" value="1">one</option>
  51. <option name="two" value="2">two</option>
  52. <option name="three" value="3" selected>three</option>
  53. <option name="four" value="4" selected>four</option>
  54. <option name="five" value="5">five</option>
  55. <option name="six" value="6">six</option>
  56. </select>
  57. <p>
  58. <input type="submit" />
  59. </form>
  60. </body>
  61. </html>
Reputation Points: 30
Solved Threads: 36
Posting Whiz
langsor is offline Offline
389 posts
since Aug 2008
Oct 9th, 2008
0

Re: Multiple select autoscroll to last item

Langsor, much thanks I cannot test the code now, but I test it within a week, and then I post if it is working.

Much thanks for taking time, you hear from me!
Reputation Points: 17
Solved Threads: 2
Junior Poster in Training
kvdd is offline Offline
55 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: how to maximize table cell height
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: FCKeditor chracter counter Problem at client side.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC