Adjusting listbox size

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
gator
Forum Newbie
Posts: 9
Joined: Mon Dec 01, 2003 10:41 am

Adjusting listbox size

Post 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?
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post by uberpolak »

Can you post some code so we can see what's causing it to stop at 11?
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post 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 >.
gator
Forum Newbie
Posts: 9
Joined: Mon Dec 01, 2003 10:41 am

Post 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");
}



?>
Last edited by gator on Tue Dec 16, 2003 3:48 pm, edited 1 time in total.
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

Have you looked at the generated source code to see if the <option>'s past 11 are being written just not displayed?
gator
Forum Newbie
Posts: 9
Joined: Mon Dec 01, 2003 10:41 am

Post by gator »

Yes they are being displayed. The user just has to use the scroll bar.
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post 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.
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post 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.
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

That won't make it a drop-down anymore, though.
gator
Forum Newbie
Posts: 9
Joined: Mon Dec 01, 2003 10:41 am

Post 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:
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post 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?
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post 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. ;)
gator
Forum Newbie
Posts: 9
Joined: Mon Dec 01, 2003 10:41 am

Post 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:
Post Reply