Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
Darrell3831
Worker
Worker



Joined: Feb 18, 2004
Posts: 244

PostPosted: Fri Aug 20, 2004 12:56 pm Reply with quote

This is as much a straight HTML question as it is a PHP question.

I'm trying to create a drop down selectable list. Here is a snipit from a piece of working code that I've created.

Code:
echo "<td align=\"center\"><nobr><SELECT NAME=\"name\">";

         
         $rights = $db->sql_query("SELECT fid from ".$prefix."_university_rights WHERE cid='$cid'");
         $total_rights = $db->sql_numrows($rights);
         if($total_rights !=0) {
            while (list($fid) = $db->sql_fetchrow($rights)) {
               $faculty = $db->sql_query("SELECT name from ".$prefix."_university_faculty WHERE fid='$fid'");
               while (list($name) = $db->sql_fetchrow($faculty)) {
                  if (get_magic_quotes_gpc())
                     $name = stripslashes($name);
                  echo "<option value=\"$cid\">$name</option>";
               }
            }
            echo "<option value=\"$cid\">-------------------------</option>";
         } else {
         echo "<option value=\"$cid\">"._UNIVERSITY_UNASSIGNED."</option>";
         echo "<option value=\"$cid\">-------------------------</option>";
         }
      echo "</select></nobr></td>";


I can't seem to find a way to have all my select drop down boxes the same size. Unless I use the little cheater trick you see here.

Where I have the line of dashes. Those dashes hold the select box out to a minimum size. Never letting it get any smaller.

How do you use the Select tag in PHP and at the same time force the box to be a minimum size no matter what data you plan to fill it with?

BTW, that snipit up above cycles through several times filling a table with rows of drop down select fields...

Thanks,
Darrell

_________________
[ Only registered users can see links on this board! Get registered or login! ] 
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Tue Aug 24, 2004 6:07 am Reply with quote

Try this and let me know if this works
Code:
<select NAME="foo" WIDTH="300" STYLE="width: 300px">

    <option>one
    <option>two
    <option>three
</select>

There is also a maxwidth CSS attribute that might need to come into play.
 
View user's profile Send private message
Darrell3831







PostPosted: Tue Aug 24, 2004 9:13 am Reply with quote

Yes!

It does work. The select box dosent shrink or grow depending on size. That's exactly what I was looking for.

Code:
<?php

echo "<select NAME=\"foo\" width=\"200\" style=\"width: 200px\" >"
   ."<option value=test>short</option>"
   ."<option value=test>longer</option>"
   ."<option value=test>longest</option>"
   ."<option value=test>this one is intentionally two long to fit</option></select>";
?>


I did look at the W3C Recommendation for select and option, but I did not see the width attribute. Sorry.

http://www.w3.org/TR/html401/interact/forms.html#control-name

Thanks,
Darrell
 
Raven







PostPosted: Tue Aug 24, 2004 9:15 am Reply with quote

The width attribute is only for NN4.x, I believe. The CSS is all that you should probably need now.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©