Adjusting listbox size
Moderator: General Moderators
Adjusting listbox size
My (dropdown) listbox only shows 11 records. I would like it to show all the records when the user opens it.
Any advice?
Any advice?
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC
Hey, thanks for getting back to me so soon!
Here is the relevant portion of my code.
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
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC
-
Paddy
- Forum Contributor
- Posts: 244
- Joined: Wed Jun 11, 2003 8:16 pm
- Location: Hobart, Tas, Aussie
- Contact:
Use the size attribute. Like this
Should give you joy.
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");
}
?>-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC