Multi-line form <select> option?

freecrm

New Member
Messages
629
Reaction score
0
Points
0
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>
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
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.
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
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.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
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:

freecrm

New Member
Messages
629
Reaction score
0
Points
0
OK - I have no idea how to create a widget so I guess that option is out.

Thanks for telling me about it anyway.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
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:

freecrm

New Member
Messages
629
Reaction score
0
Points
0
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..... :(
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Server config issue; try the link again, if you're curious. However, it sounds like you found a better solution.
 
Top