+ Reply to Thread
Results 1 to 8 of 8

Thread: Multi-line form <select> option?

  1. #1
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Multi-line form <select> option?

    This isn't as simple as the title suggests.

    I know you can have multiple options, as successive lines BUT...

    I have a dynamically generated menu from a longtext database field. I don't want the menu to extend beyond the limit of my wrapper, so I set style="width:650px;".

    However, this means that anything called from the DB that is longer than the field is not displayed.

    I tried specifiying a css text-overflow and overflow but to no avail.

    Anyt ideas?

    Code:
    <select name="ChassConstr" id="ChassConstr" style="width:650px;">
              <?php do { ?>
            <option value=
                      "<?php echo $row_chassis_constr_recordset['chassis_constr'];?>"
                      <?php if (!(strcmp($row_chassis_constr_recordset['chassis_constr'], $row_detail_recordset['chassis_constr']))) {echo "selected";} ?>
                >
                  <?php echo $row_chassis_constr_recordset['chassis_constr'];?>
                </option>
               <?php
       } while ($row_chassis_constr_recordset = mysql_fetch_assoc($chassis_constr_recordset));
         $rows = mysql_num_rows($chassis_constr_recordset);
         if($rows > 0) {
          mysql_data_seek($chassis_constr_recordset, 0);
          $row_chassis_constr_recordset = mysql_fetch_assoc($chassis_constr_recordset);
         }
       ?>
    </select>

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Multi-line form <select> option?

    What specific behavior do you want?

    Select elements are typically rendered using native widgets (menus, listboxes, dropdown lists), which has very limited behavior for dealing with long lines, given their narrow usage. Even when they are rendered with widgets defined by the browser, they usually have the same limitations for the same reasons. If you want some other behavior, you'll have to implement your own widget using other HTML elements and use a hidden form input.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: Multi-line form <select> option?

    Thanks for the response.

    I am simply trying to mimic the text-overflow: wrap; function in css, so that, if the list/menu is fixed at say 650px, any row contents that exceed the physical boundary of the select box will wrap to nl.

    Because the list is generated from a longtext field, it may have to wrap numerous times before all characters are shown for each select option.

    I've searched and searched and cannot find a suitable answer yet.

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Multi-line form <select> option?

    You can create your own widget. You'll need to implement line selection and hilighting by hooking the click event. In your handlers, update a hidden <input> based on the current selection, fire a change event (though you could rely on the change event for the hidden input) and prevent the default click handler. If you want a dropdown list, you'll also need to implement that.
    Last edited by misson; 04-09-2010 at 04:53 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: Multi-line form <select> option?

    OK - I have no idea how to create a widget so I guess that option is out.

    Thanks for telling me about it anyway.

  6. #6
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Multi-line form <select> option?

    It's a combination of HTML, JS for behavior and CSS for styling. Here's an (incomplete) example of a multiline select widget.
    Last edited by misson; 04-11-2010 at 07:31 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  7. #7
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: Multi-line form <select> option?

    Quote Originally Posted by misson View Post
    It's a combination of HTML, JS for behavior and CSS for styling. Here's an (incomplete) example of a multiline select widget.
    Page does not exist..

    Anyhoo, I managed to get round the problem with an ajax call - select a short version and the rest appears as if by magic!

    Thanks mission - as usual very helpful.

    Now if only I could find out what happened to my databases.....

  8. #8
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Multi-line form <select> option?

    Server config issue; try the link again, if you're curious. However, it sounds like you found a better solution.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Line break while writing txt file using php & form data
    By vaibhavy in forum Programming Help
    Replies: 3
    Last Post: 03-31-2010, 11:28 AM
  2. HTML <select> FORM ?
    By noivel in forum Programming Help
    Replies: 5
    Last Post: 03-21-2010, 02:41 PM
  3. PHP contact form styling (line spacing)
    By xxll_martin_llxx in forum Programming Help
    Replies: 3
    Last Post: 07-24-2008, 10:09 AM
  4. Line breaks in Form Data
    By Adam01 in forum Programming Help
    Replies: 8
    Last Post: 01-12-2008, 03:09 PM
  5. [REQ] Multi-User / Multi-Blog Install
    By Starshine in forum The Marketplace
    Replies: 10
    Last Post: 09-28-2006, 11:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers