Home » SQL & PL/SQL » SQL & PL/SQL » Selecting multiple values from dropdown
Selecting multiple values from dropdown [message #185266] Mon, 31 July 2006 17:11 Go to next message
anngold
Messages: 9
Registered: July 2006
Junior Member
I use htp and sql to create web forms and I'm stuck on how to turn a dropdown list into a dropdown where multiple values can be selected.

Here are the pieces of my existing code that I need to modify:

htp.p('<TD>');
htp.formSelectOpen( cname => 'MACH_TYPE' );
htp.formSelectOption('ANY',cattributes => 'value="%"');
for p in prods loop
htp.formSelectOption(p.prod_line,cattributes => 'value="'||p.prod_line_short||'"');
end loop;
htp.formSelectClose;
htp.p('</TD>');
.
.
.
--this builds a stored query for later recall
if name_array(counter) = 'MACH_TYPE' then
v_mach_type := value_array(counter);
v_query := v_query||name_array(counter)||'='||value_array(counter)||amp;
if v_mach_type is null then
v_mach_type := '%';
end if;
end if;
.
.
.
--this is part of the dynamic cursor that gets built.
if trim(v_mach_type) is not null then
sel := sel||' and upper(ins.prod_line) like '''||v_mach_type||''';
end if;

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

I'd really appreciate any help you can offer. Thanks.
Re: Selecting multiple values from dropdown [message #185531 is a reply to message #185266] Wed, 02 August 2006 03:12 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
I don't think HTML supports a multi-select dropdown list - if it does then that's my learning experience for the day taken care of.
Re: Selecting multiple values from dropdown [message #185591 is a reply to message #185266] Wed, 02 August 2006 08:38 Go to previous messageGo to next message
anngold
Messages: 9
Registered: July 2006
Junior Member
I believe I can change this:

htp.formSelectOpen( cname => 'MACH_TYPE' );

to this:

htp.formSelectOpen( cname => 'MACH_TYPE', cattributes => 'MULTIPLE' );

However, I'm not sure how to process the selections after that.

Thanks.
Re: Selecting multiple values from dropdown [message #185598 is a reply to message #185591] Wed, 02 August 2006 09:01 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Ok. Learning experience checked.

I would guess that it will return several parameters of the same name as the drop down list, with different values.

Are you running this through Mod_Plsql?
Re: Selecting multiple values from dropdown [message #185599 is a reply to message #185598] Wed, 02 August 2006 09:05 Go to previous messageGo to next message
anngold
Messages: 9
Registered: July 2006
Junior Member
No not running it through Mod_Plsql. Not familiar with that.

I just need to know how to handle the multiple values in the other two parts of the code that I listed.

Thanks.
Re: Selecting multiple values from dropdown [message #185601 is a reply to message #185599] Wed, 02 August 2006 09:18 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
I strongly suspect that you'll get multiple rows in NAME_ARRAY for the value 'MACH_TYPE'
Re: Selecting multiple values from dropdown [message #185602 is a reply to message #185601] Wed, 02 August 2006 09:24 Go to previous messageGo to next message
anngold
Messages: 9
Registered: July 2006
Junior Member
Right, that's what happens. How do I handle that?
Re: Selecting multiple values from dropdown [message #185604 is a reply to message #185602] Wed, 02 August 2006 10:01 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
It's tricky to say how you handle that - out of the two of us, you're the one who knows what you're trying to do.

You probably want to step through all the rows in NAME_ARRAY that are for MACH_TYPE and build up a quote enclosed, comma seperated list of the values from VALUE_ARRAY
eg
'value_1','value_2','value_3'

then instead of using LIKE or = clauses in the dynamic queries, you could use an IN clause.
Re: Selecting multiple values from dropdown [message #185606 is a reply to message #185604] Wed, 02 August 2006 10:13 Go to previous messageGo to next message
anngold
Messages: 9
Registered: July 2006
Junior Member
I'll try to make that work. Thanks.
Re: Selecting multiple values from dropdown [message #185619 is a reply to message #185606] Wed, 02 August 2006 12:51 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
See demo_pkg.my_form
  • Attachment: DEMO_PKG.PKB
    (Size: 7.75KB, Downloaded 224 times)
  • Attachment: DEMO_PKG.PKS
    (Size: 1.87KB, Downloaded 203 times)
Previous Topic: Question on Functions
Next Topic: decode/case
Goto Forum:
  


Current Time: Tue Dec 06 06:47:56 CST 2016

Total time taken to generate the page: 0.06484 seconds