Page 1 of 1

Adjusting listbox size

Posted: Mon Dec 15, 2003 2:48 pm
by gator
My (dropdown) listbox only shows 11 records. I would like it to show all the records when the user opens it.

Any advice?

Posted: Mon Dec 15, 2003 3:25 pm
by uberpolak
Can you post some code so we can see what's causing it to stop at 11?

Posted: Mon Dec 15, 2003 4:35 pm
by microthick
There is probably a symbol being outputted in the select box that stops the html from displaying.

Look for greater than or less than signs... < or >.

Posted: Tue Dec 16, 2003 11:39 am
by gator
Hey, thanks for getting back to me so soon!

Here is the relevant portion of my code. :)

Code: Select all

<?php

function createSelect ( $Sname, $table, $select_id="", $name ) {
# $Sname is the name to be applied to the select control.
# $table is the name of the table to query.
# NOTE: This function assumes you are using a lookup table that has 2 fields (id,name) or you only name those 2 fields in your sql statement.
# $any 0=Without the "Any" option, 1=With the "Any" option, this is a NULL value.
# $curr_id is used to set the "SELECTED" flag on the select control.

    include("config.php");

    
         $sql = "SELECT * FROM $table ORDER BY $name";
    

    $results = mysql_query($sql);
    printf("<select name="$Sname">\n");



    while ($row = mysql_fetch_array($results)):

        if ($Sname == "urgency") {
            $id = $row["urgency_id"];
            $name = $row["description"];}

        if ($id == $select_id) {
           
            printf("<option SELECTED value="$id">$name\n");

        } else {
            
             printf("<option value="$id">$name\n");
        }
    endwhile;
    printf("</select>\n");
}



?>

Posted: Tue Dec 16, 2003 12:26 pm
by microthick
Have you looked at the generated source code to see if the <option>'s past 11 are being written just not displayed?

Posted: Tue Dec 16, 2003 3:46 pm
by gator
Yes they are being displayed. The user just has to use the scroll bar.

Posted: Tue Dec 16, 2003 3:53 pm
by microthick
Oh, we were totally interpretting your problem differently.

Those limits are set by the browser itself.

For instance, IE only shows 11. Mozilla Firebird shows 20.

I doubt you can change those.

Posted: Tue Dec 16, 2003 4:01 pm
by Paddy
Use the size attribute. Like this

Code: Select all

<?php

function createSelect ( $Sname, $table, $select_id="", $name ) { 
# $Sname is the name to be applied to the select control. 
# $table is the name of the table to query. 
# NOTE: This function assumes you are using a lookup table that has 2 fields (id,name) or you only name those 2 fields in your sql statement. 
# $any 0=Without the "Any" option, 1=With the "Any" option, this is a NULL value. 
# $curr_id is used to set the "SELECTED" flag on the select control. 

    include("config.php"); 

    
         $sql = "SELECT * FROM $table ORDER BY $name"; 
         $size = mysql_num_rows($results);

    $results = mysql_query($sql); 
    printf("<select name="$Sname" size="$size">\n"); 

    while ($row = mysql_fetch_array($results)): 

        if ($Sname == "urgency") { 
            $id = $row["urgency_id"]; 
            $name = $row["description"];} 

        if ($id == $select_id) { 
            
            printf("<option SELECTED value="$id">$name\n"); 

        } else { 
            
             printf("<option value="$id">$name\n"); 
        } 
    endwhile; 
    printf("</select>\n"); 
} 



?>
Should give you joy.

Posted: Tue Dec 16, 2003 4:34 pm
by microthick
That won't make it a drop-down anymore, though.

Posted: Tue Dec 16, 2003 4:51 pm
by gator
I think Microthick has got it.

Paddy your solution works but it changes the listbox from a dropdown listbox to a listbox.

please forgive my teminology.

Thanks guys :wink:

Posted: Tue Dec 16, 2003 4:53 pm
by Paddy
gator wrote:Yes they are being displayed. The user just has to use the scroll bar.
I was assuming from this that is what gator wanted. I think I am confused.

What I provided was a box with no scroll bar. What is it that you want gator?

Posted: Tue Dec 16, 2003 5:04 pm
by Paddy
gator wrote:I think Microthick has got it.

Paddy your solution works but it changes the listbox from a dropdown listbox to a listbox.

please forgive my teminology.

Thanks guys :wink:
Bah, it's not you, it's me. Trust me. ;)

Posted: Wed Dec 17, 2003 7:58 am
by gator
Good point Paddy, my apologies. You gave a solution to the problem I stated. I need to be more clear in the future. :oops: