Some confusion here, I think. There is no onChange in perl, nor can there be. Your perl scripts run on the server, in response to requests from browsers. They neither know nor care what is being selected on the page, until the point where you hit the submit button and the selections are passed back to the server.

To do what you want - ie to change the nature of a form so that it submits when a selection is made, rather than when a button is pushed - you need to change the way the browser behaves, not the server. Which makes it a javascript question and explains the rather terse replies you'll find here.

This is the sort of question google excels at, by the way. Any one of the 5,810 pages it returns when you search for 'select box onChange' will have something useful to say.

But since you're here, this is how i would do it:

<select name="choose" onChange="this.form.submit()"> <option value="mumble"> mumble </option> </select>

Or for a navigation drop-down, which I expect is what you're doing:

<select name="choose" onChange="document.location.href=this.options[th +is.selectedIndex].value"> <option value="/path/page.html"> mumble </option> </select>

Which doesn't even need any perl on the server side. I'd better stop there before I get in any more trouble.


In reply to Re: is there something like onChange action for a selection list ? by thpfft
in thread is there something like onChange action for a selection list ? by jvd

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.