Getting Pull down to work right

admin

Administrator
Staff member
Hey all,

Here is a simple pull down for our server list:

Server List :
<select name="server">
<option value="All">All</option>
<option value="Classified">Classified</option>
<option value="FCM">FCM</option>
<option value="FCM/CTASC">FCM/CTASC</option>
<option value="Hitachi">Hitachi</option>
<option value="mt01">mt01</option>
<option value="mt02">mt02</option>
<option value="mt03">mt03</option>
<option value="mt04">mt04</option>
<option value="mt05">mt05</option>
<option value="mt06">mt06</option>
<option value="mt07">mt07</option>
<option value="mt08">mt08</option>
<option value="mt09">mt09</option>
<option value="mt10">mt10</option>
<option value="mt11">mt11</option>
<option value="mt12">mt12</option>
<option value="E25K-sc0">E25K-sc0</option>
<option value="E25K-sc1">E25k-sc1</option>
<option value="mt13">mt13</option>
<option value="Cluster1 mt14-mt15">Cluster1 mt14-mt15</option>
<option value="mt14">mt14</option>
<option value="mt15">mt15</option>
<option value="mt16">mt16</option>
<option value="Cluster2 mt17-mt18">Cluster2 mt17-mt18</option>
<option value="mt17">mt17</option>
<option value="mt18">mt18</option>
<option value="mt19">mt19</option>
<option value="mt23">mt23</option>
<option value="mt24">mt24</option>
<option value="mt25">mt25</option>
<option value="mt26">mt26</option>
<option value="mt27">mt27</option>
<option value="mt28">mt28</option>
<option value="mt29">mt29</option>
<option value="Zeus">Zeus</option>
<option value="artemis">artemis</option>
<option value="liwws1">liwws1</option>
<option value="liwws2">liwws2</option>
<option value="liwws3">liwws3</option>
<option value="logsapix">logsapix</option>
<option value="Switch1MSFC">Switch1MSFC</option>
<option value="Switch2MSFC">Switch2MSFC</option>
<option value="5307r135s1">5307r135s1</option>
<option value="5307r135s2">5307r135s2</option>
<option value="css11503">css11503</option>
</select>

When it displays through html it shows only about 15 ( I think by default) and you have to scroll through the rest. It works as it should.

I want to add the ability to select multiple servers but still retain the afore mentioned look. So I added after the select this:

Server List :
<select name="server" multiple size=1>

And now it allows multiple selections but the window is only 1 line tall, hence size=1. But I dont want it bigger by default. I want it the same size as my other single line drop downs.

So my question is, How can I have the list like the way it is without the "multiple" added but still allow multiple items selected? Is it possible in html or do I have to use JS to do this?

Also, now my variable "server" becomes an array. I want to take that and dump it into my database. Where in my code do I make it an array to have it insert multiple enties? Php code below.

<?php
//Create variable names from the html input
$id=$_POST['id'];
$name=$_POST['name'];
$server=$_POST['server'];
$dbname=$_POST['dbname'];
$event=$_POST['event'];
$description=$_POST['description'];
$wyear1=$_POST['wyear1'];
$wmonth1=$_POST['wmonth1'];
$wday1=$_POST['wday1'];
$whour1=$_POST['whour1'];

if (!get_magic_quotes_gpc())
{
$id = addslashes($id);
$name = addslashes($name);
$server = addslashes($server);
$dbname = addslashes($dbname);
$event = addslashes($event);
$description = addslashes($description);
$wyear1 = addslashes($wyear1);
$wmonth1 = addslashes($wmonth1);
$wday1 = addslashes($wday1);
$whour1 = addslahses($whour1);
}

$wdate = ($wyear1."-".$wmonth1."-".$wday1." ".$whour1);

@ $db = new mysqli('localhost', 'blah', 'blah', 'dc');
if (mysqli_connect_errno())
{
echo 'ERROR: Could not connect to database. Check that the db is running and that the server is up.';
exit;
}
$query = "insert into sdata values
('".$id."', '".$name."', '".$server."','".$dbname."','".$description."', now(), '".$wdate."', '".$event."',refnum)"
;
$result = $db->query($query);
if ($result)
echo $db->affected_rows.' record confirmed submitted into data base.';
$db->close();
?>

I imagine here:

$server=$_POST['server[]'];
I added the "[]" after server.

I am close or way off here?

Thanks!You can use CSS to increase the height:

<select size="1" multiple style="height: 300px;">
<option>a;sldkfj</option>
<option>:Lskj</option>
<option>a;lsdfj;lskj</option>
</select>


KDLAIs shows as the same that I am trying to avoid. :(

try this:
<select name="Name">
put 15-20 <option values="kjdfkj">lkasjdlkja</option> here
</select>

it shows as one line until you mouse click on it, then it expands. This is the functinoality that I want with the "multiple tag"

Now try this:

<select name="Name" multiple size="1">
put 15-20 <option values="kjdfkj">lkasjdlkja</option> here
</select>

See the difference? this is what I want to avoid. I hope I am making since?So, in essence, you want all the options to appear = you can see everything you've chosen at one time, rather than having the user scroll through them one by one.

Are you sure that a drop down, for so many entries, is the best option? Check boxes may be a better, from the user's standpoint. Few users understand the concept of a "multiple dropdown." Then, if you complicate it by having more than a few choices (like 15-20), there's more chance for error -- someone clicking on the wrong thing or accidentally deselecting their other choices. Just some food for thought.

Here's something you might find useful: <!-- m --><a class="postlink" href="http://www.phpguru.org/static/MultipleSelect.html">http://www.phpguru.org/static/MultipleSelect.html</a><!-- m -->
It combines the select with the checkbox method.

Good Luck :)
KDLASo, in essence, you want all the options to appear = you can see everything you've chosen at one time, rather than having the user scroll through them one by one.

Well I want the options to appear as they do with out the multiple in the slect tag. When I dont have multiple inserted I still get about 10 or so listed but with a menu bar that allows you to scroll through the rest. So yes I want that functionality with the ability to select multiple items.

Are you sure that a drop down, for so many entries, is the best option? Check boxes may be a better, from the user's standpoint. Few users understand the concept of a "multiple dropdown." Then, if you complicate it by having more than a few choices (like 15-20), there's more chance for error -- someone clicking on the wrong thing or accidentally deselecting their other choices. Just some food for thought.

Yeah this is what I was shooting for. Where I work is a Data Center and this is a tool for us. So I think everyone will get it.
I dont want a menu with predefined items showing when the page loads. I want it to show only one line like the rest of the non multiple drop downs. But when the user clicks on the drop down with the ability to multiple select items I want it looking like the rest. It keeps everything looking the same.


Here's something you might find useful: <!-- m --><a class="postlink" href="http://www.phpguru.org/static/MultipleSelect.html">http://www.phpguru.org/static/MultipleSelect.html</a><!-- m -->
It combines the select with the checkbox method.

Good Luck :)
KDLA[


Thanks for the link, but it still shows 4 items from the load. Thats what I am trying to avoid.

Any more suggesstions? This is turning out to be a stumper. Thanks again!
 
Back
Top