Well I wasn't sure what would be the best way for management types to be able to sort the items. When I found this demo, it seemed like the perfect solution.

I have been using perl for years for things like data munging, converting, etc. What I'm not sure of is how to connect the non-perl stuff to perl.

I have a perl script that runs, pulls in data in the most useful format it can access, munges it and creates an sqlite database out of it. Now, I'm working on the other half where a manager will use a webpage to access data specific to him, based on his login, and allow him to rearrange the order of the items.

So, let's assume he's logged in, now he gets taken to a page like the one in the demo. Based on his login, the CGI has extracted relevant items from the database. In the first version, I generated an html table from the results of my database query. Instead, I would like to generate the javascript screen shown in the demo. After he rearranges the items, I want him to be able to hit a save button or something. At that point, I assume I will need to traverse the dom stuff in order to extract the ordering that he has just imposed on the list.

But I don't yet see how the pieces fit together. What does the CGI script that invokes the Sortable function look like? How and when does my CGI script get control back after the javascript code has finished running so I can extract the changes that were made?

As a start, could you show me how to get the Sortable demo working from CGI. Does the sortable stuff go into its own .js file or is it embeded in the perl script? How is control passed back and forth?

I would like to see a simple conversion of the sortable demo so that it is started by or contained within a CGI script, the user rearranges the items on the screen, pushes a button, and them the CGI gets control back and prints the new order. This would help me to understand how they call and return from each other.

This is very powerful to be able to interact with external libraries that are very good at doing specific tasks. Any books, articles, etc. about using perl with other toolkits, languages, etc. would be gratefully accepted.

Thanks for you help and encouragement - it really helps! I'll send some time with the template toolkit but, again, I'm not sure how to tie all the pieces together between javascript and perl. Are there some examples I could study where CGI scripts invoke javascript toolkits and then get control back for further processing? Simple stuff just to illustrate would be fine. If templates were used too, that would be even better. Leo


In reply to cgi scripts running javascript and passing control back and forth by yaconsult
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.