I have the following code to produce a drop down.

It has some Options with more than one word ie. "Desktop Products"

but when i am reading the form value using

param('technology');

it returns only "Desktop" not "Desktop Products"

Source Code follows

calling the function like this

print "<select name='technology'>"; $tech_selected=param('technology'); &print_option('t',$tech_selected); print "</td></tr>"; sub print_option{ my ($opt,$selected)=@_; my ($arr_val,$where,$ind,$sql); my ($dbh,$sth); if ($opt eq 't'){ # Build Tech Drop down $sql="select distinct(technology) from t_pomap"; }else{ # Build NPO Drop down $sql="select distinct(npo) from t_pomap"; } $dbh = DBI->connect('DBI:Pg:dbname=test', 'db_user', ''); $sth=$dbh->prepare ($sql); $sth->execute(); $ind=0; while(my @options=$sth->fetchrow_array()){ if ($selected eq $options[0]){ print "<option value=$options[0] selected=$options[0]>$options[0] +</option>"; } else { print "<option value=$options[0] >$options[0]</option>"; } }#endwhile $dbh->disconnect(); }#endsub

Edited by davorg: tidied formatting.


In reply to Creating Multi-word Options by beginr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.