Results 1 to 6 of 6

Thread: Dynamic Width Change of Listbox/Combobox

  1. #1
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Dynamic Width Change of Listbox/Combobox

    Does anyone know of any javascript code that will allow you to dyamically change the width of a listbox/combobox? I'm really looking for something that will allow me to use the mouse to resize the combobox (i.e. drag the width). Thanks.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Using this library:

    http://www.walterzorn.com/scripts/wz_dragdrop.zip

    from:

    http://www.walterzorn.com/dragdrop/dragdrop_e.htm

    With this markup:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <script type="text/javascript" src="wz_dragdrop.js"></script>
    <form action="">
    <div id="name2" style="width:75px;height:75px;position:absolute;border:7px solid green;"><select  style="width:100%;height:100%;" size="2" name="bob">
    <option value="ed">Hey</option>
    <option value="ed">Hey</option>
    <option value="ed">Hey</option>
    <option value="ed">Hey</option>
    <option value="ed">Hey</option>
    <option value="ed">Hey</option>
    <option value="ed">Hey</option>
    <option value="ed">Hey</option>
    </select></div>
    </form>
    <script type="text/javascript">
    <!--
    
    SET_DHTML("name2"+RESIZABLE+HORIZONTAL+VERTICAL);
    
    //-->
    </script>
    </body>
    </html>
    Works fairly well, you need to hit shift, then left click on the border to resize it.
    Last edited by jscheuer1; 05-09-2006 at 09:03 AM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This is great except that it is not a combobox/dropdown box. How do I fix this?
    thanks.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    What is a combobox/dropdown box? I thought it was a select, so that is what I used. Perhaps you want a different sort of select type, you can remove the size attribute, that will make it more of a drop down but, makes resizing it in the vertical dimension rather pointless. Let me know more specifically and I will see about adapting it.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The size fix worked. Thanks.
    Is there any way to disable the vertical size chage? Also, can the behavior be changed so that you don't have to hold the shift key to resize?

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    To limit the vertical resizing use something like so:

    Code:
    SET_DHTML("name2"+RESIZABLE+HORIZONTAL+VERTICAL+MAXHEIGHT+30+MINHEIGHT+30);
    for your call, 30 is the number of pixels. At the same time, set the height of the container division at or slightly below this amount:

    Code:
    <div id="name2" style="width:75px;height:30px;position:absolute;border:7px solid green;">
    To eliminate the need for the ctrl or shift keys, edit the external script file. Find this line:

    Code:
    	this.modifKey = this.e.modifiers? this.e.modifiers&Event.SHIFT_MASK : (this.e.shiftKey || false);
    Change it to:

    Code:
    	this.modifKey = true //this.e.modifiers? this.e.modifiers&Event.SHIFT_MASK : (this.e.shiftKey || false);
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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