As I said before, you're not converting JavaScript to Perl. You say you can generate HTML, that's all you want to do here, simply generate the ordered list (as per the jQuery UI example you've found) using Perl to query a database.

jeffa wrote a nice tutorial HTML::Template Tutorial which you should read. Simply use a <TMPL_LOOP> to create list items (<li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span><TMPL_VAR NAME=ITEM_NO>) based the results of your database results. Consider your template file as a standard HTML file, with some additional tags which HTML::Template populates before returning the HTML with your values. The first step here, before you do any Perl code, is to get a stand alone HTML file running this example code which works, then convert that into a template file.

jeffa has provided working examples in that tutorial, all you'd need to do adapt the example, including your own database queries, include the jQuery.js and jQuery UI files (this is documented on the jQuery site).


In reply to Re: cgi scripts running javascript and passing control back and forth by marto
in thread How to allow a user to reorder rows from a database using a web form? by yaconsult

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.