Hi Monks,

I am using CGI-Application and HTML-Template to create a form where values from database are extracted and displayed to uers. My form requires 2 dropdown lists e.g. list1 and list2. Elements in list2 are controlled by selected value in list1.

So when user selects an element from list1, form is submitted and new values are populated in drop down list2 but elements in list1 goes back to default list order where as i want the selected item to be the 1st item in drop down. Here is html for drop down:-

<tr bgcolor="#ffffff"> <td class="colhead">List1</td> <td><select name="list1" size="1" style="background-color:#DDD;" onc +hange="admin.submit();"> <!-- TMPL_LOOP NAME=depts --> <option value="<!-- TMPL_VAR NAME=id -->"><!-- TMPL_VAR NAME=dn -- +> <!-- /TMPL_LOOP --> </select> </td> </tr> <tr bgcolor="#ffffff"> <td class="colhead">List2</td> <td><select name="list2" size="1" style="background-color:#DDD;" onc +hange="admin.submit();"> <!-- TMPL_LOOP NAME=emps --> <option value="<!-- TMPL_VAR NAME=id -->"><!-- TMPL_VAR NAME=ename + --> <!-- /TMPL_LOOP --> </select> </td> </tr> .... ....

Considered (gellyfish): delete or mark OT this is a Javascript Question
Unconsidered (holli): Enough Keep votes (Keep/Edit/Delete : 11/12/6)


In reply to Submitting form when drop down value changes by bar10der

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.