HTML Multiple Select

A

Akshat Trivedi

Hi,

I am trying to create a dropdown menu in HTML using the <SELECT> tag. I
need to select multiple items but the constraint I have is that the
size has to be 1.

<select name="3" multiple size="1">
<option>one
<option>two
<option>three
<option>four
<option>five
<option>six
</select>

With the above approach I do not get a drop down but a list with only 1
option visible. I need the dropdown and multiple select. The dropdown
menu could have a scroll bar in it. Can someone suggest a solution.

Thanks,
AT
 
P

Peter Kirk

Akshat Trivedi said:
I am trying to create a dropdown menu in HTML using the <SELECT> tag. I
need to select multiple items but the constraint I have is that the
size has to be 1.

<select name="3" multiple size="1">
<option>one
<option>two
<option>three
<option>four
<option>five
<option>six
</select>

With the above approach I do not get a drop down but a list with only 1
option visible. I need the dropdown and multiple select. The dropdown
menu could have a scroll bar in it. Can someone suggest a solution.

You have posted to a Java group - maybe better to find one that deals with
HTML
Here is a site about HTML:
http://www.htmlcodetutorial.com/forms/_SELECT.html
 
R

Roland

Hi,

I am trying to create a dropdown menu in HTML using the <SELECT> tag. I
need to select multiple items but the constraint I have is that the
size has to be 1.

<select name="3" multiple size="1">
<option>one
<option>two
<option>three
<option>four
<option>five
<option>six
</select>

With the above approach I do not get a drop down but a list with only 1
option visible. I need the dropdown and multiple select. The dropdown
menu could have a scroll bar in it. Can someone suggest a solution.

Thanks,
AT
Since it has nothing to do with Java, you'd better ask this in a group
like comp.infosystems.www.authoring.html
--
Regards,

Roland de Ruiter
___ ___
/__/ w_/ /__/
/ \ /_/ / \
 
T

Tom Dyess

Akshat Trivedi said:
Hi,

I am trying to create a dropdown menu in HTML using the <SELECT> tag. I
need to select multiple items but the constraint I have is that the
size has to be 1.

<select name="3" multiple size="1">
<option>one
<option>two
<option>three
<option>four
<option>five
<option>six
</select>

With the above approach I do not get a drop down but a list with only 1
option visible. I need the dropdown and multiple select. The dropdown
menu could have a scroll bar in it. Can someone suggest a solution.

Thanks,
AT

I don't think a multiple select is possible with a combobox/dropdown in
current HTML standards. It's either combobox which is a single selection, or
a multiselect which looks like a textarea. I would check the HTML newsgroups
or google.com to make sure though.
 
Joined
Jul 12, 2008
Messages
3
Reaction score
0
use php instead

I use php for webforms :flute:

java is much too complicated! :-(

use java for more computational things,
for GUI things just use php


eg here is a php program to echo an element
of name xyz from a webform in php say echo_xyz.php


<?php

echo $_REQUEST[ "xyz" ] ;

?>


that will deal with GET and POST etc. it doesnt get
any simpler than that. You need the more recent versions
of php for _REQUEST[]. But all servers will have recent
php's.

furthermore people CANNOT view files which end in .php
as the server executes them regardless of directory.

its not like perl where the scripts have to go in /cgi-bin



multiple select looks complicated,

here is a php page which seems to explain both the html and php:

http://www.onlinetools.org/tricks/using_multiple_select.php

as you can see, the php is advanced but straightforward.

I recommend you use _REQUEST instead of _POST
as _POST only deals with POST actions, _REQUEST
is a more recent addition to php which deals with all cases.

earlier php's needed a complicated function to
unify the different html form actions.


I guess you have to use the Java version of that php,

it must be very tricky to do in Java which is why noone
here has an answer!
 
Joined
Jul 12, 2008
Messages
3
Reaction score
0
full working example via php

:damnmate:

I realise this is a Java thread!

if you want to create a graph for a financial website
you use Java, :stupido:

but for the problem here you use php, which
answers the original question. 8)

experimenting with the URL I gave above I
have a debugged complete example how to do it via
HTML and php.

you need 2 files: multi.html and multi.php
which can be placed in any directory of
a website. furthermore your PC doesnt need php,
the interesting thing about php is it is all done
at the server. for instance it means noone
can steal your php code and it should run
with most computers.

-------------------------------------------
multi.html is:

<html>
<head>
<title>multi</title>
</head>
<body>


<form method="post" action="multi.php">

<p>menu:
<select name="car[]" multiple="multiple">
<option value="mercedes">mercedes</option>

<option value="vw">vw</option>

<option value="audi" selected>audi</option>

<option value="trabant" selected>trabant</option>

</select>

<input type="submit">

</form>


</body>
</html>

----------------------------------------------------

multi.php is:

<?php

$cars=$_REQUEST['car'];

if( $cars )
{
foreach( $cars as $car ){ echo $car ; echo " " ; }
}

?>

------------------------------------------------------------

with the example you visit multi.html with a browser,
make a multiple selection of the cars you want, press submit
and it will list the cars selected separated by spaces. :captain:

I avoided using unnecessary php constructs. :veryprou:

like Java, php also uses the C syntax. php can be
intermixed with HTML and that is where a lot of the
power is: you can use HTML <form> to give php
GUI functionality.

to see the power of php I wrote a simple mailing list
program in maybe 20 lines of php. it is a 1-way mailing
list which emails everyone in the list but replies
go to a different address. the script sends an email

with the persons name in the subject line and

hi richard,

....

as the message.


on the HTML side people are recommended to use
checkboxes instead of multi-select menus as
checkboxes can be processed much more powerfully
as you can access each checkbox directly.

:saint:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top