Greetings, fellow monks
To help the interns at my town hospital set up their shift calendars I wrote an openoffice base macro (in OObasic, bleh) after some time I rewrote it in java to make it portable, then when I thought about the hassle of having untrained user open a terminal and type "java -jar mything --xls input.xls" I decided to set it up as a web application.
There started a painful trip, unknowing of frameworks like sails I wrote it in nodejs (even though I hate javascript with a passion) and cobbled together a rag tag session system to prevent users from having to register themselves. After falling in love with perl I decided to get rid of that crap and rewrite it in perl using Catalyst.
After some fiddling around I managed to setup a session system using cookies so the server can keep track of data added by users during their sessions, problem is I am now coding the ability to delete any data they have entered and I hit quite a roadblock : how do I do that?
Data is submitted to the server in the url using a GET request and the following scheme :
http://127.0.0.1:3000/serviceform?nom_service=service&nb_jours_repos=1
This is a get request to record data, now to delete it I whipped up some javascript code to make users able to point and click at whatever data they want to delete (data is displayed that way in the template : )
[% FOREACH key IN services.keys -%]
<li onclick="select(this)">service : [%key%] jours de re
+pos: [%services.$key.nb_jours%]
interieur : [%services.$key.interieur%]</li>
[% END -%]
Because I save everything in a hash of hashs inside my session.
here is the form used to enter data that is sent to the server and displayed on the webpage :
<form>
<label for="ns">nom du service </label>
<input type="text" name="nom_service" id="ns" value="s
+ervice"/>
<label for="nbjdr">nombre de jours de repos</label>
<input type="number" id="nbjdr" name="nb_jours_repos"
+value=1 />
<label for="int">service d'intérieur?</label>
<input type="checkbox" id="int" name="interieur" />
<input type="submit" value="ajouter"/>
<input type="button" class="remove" onclick="remove()"
+ value="supprimer"/>
</form>
The remove function called is a javascript one to delete the li nodes with the selected class.
I can set any of those list item class to selected but what should happen when I press the delete button, I need to delete those entries on the server as well, not just in the client browser. I think some kind of request should be in order but I haven't the foggiest about how it should be handled, maybe a special case of submit with a hidden delete boolean set to true..? If anyone cares to give me a hint about the best way to do it it would be most welcome.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|