I have learned how to display variables in template toolkit with <% varname %>. However, these variables are being named from withing my dancer app and displayed on the template. Is there a way to display variables that a user is entering as they are entering it. So that if I have a menu like form where a user can pick several items and see them each added one by one in a list format before pressing a second submit button that submits his entire lists of entries? It would be a bit like a shopping cart but instead of the items being put in the cart they are displayed right there in the form as they are added. Thanks for any ideas. Richard
On Mon, 2015-09-21 at 13:09 -0500, Richard Reina wrote:
I have learned how to display variables in template toolkit with <% varname %>. However, these variables are being named from withing my dancer app and displayed on the template. Is there a way to display variables that a user is entering as they are entering it.
Not as part of TT - that all happens server side.
So that if I have a menu like form where a user can pick several items and see them each added one by one in a list format before pressing a second submit button that submits his entire lists of entries? It would be a bit like a shopping cart but instead of the items being put in the cart they are displayed right there in the form as they are added.
In which case you have 2 options: 1. Process it client-side with javascript (not recommended) 2. Make each "addition" a new request, and store server-side You could also do a combination with AJAX-type calls, which is probably the best "modern" way of doing it, although it will be more complicated than option 2. Andy
2015-09-21 13:20 GMT-05:00 Andrew Beverley <andy@andybev.com>:
On Mon, 2015-09-21 at 13:09 -0500, Richard Reina wrote:
I have learned how to display variables in template toolkit with <% varname %>. However, these variables are being named from withing my dancer app and displayed on the template. Is there a way to display variables that a user is entering as they are entering it.
Not as part of TT - that all happens server side.
So that if I have a menu like form where a user can pick several items and see them each added one by one in a list format before pressing a second submit button that submits his entire lists of entries? It would be a bit like a shopping cart but instead of the items being put in the cart they are displayed right there in the form as they are added.
In which case you have 2 options:
1. Process it client-side with javascript (not recommended) 2. Make each "addition" a new request, and store server-side
Hi Andy, So if I have the users choices (that I want to re-display as a list) coming back in the POST. Once I have turned them into a session variable what is the best way to re-request the page? Should I just do a redirect or would some other method be better? post '/featadd' => sub { # let user enter info my $input_hash = { game_id => param('game_id'), spsrd_chlg_id => param('spsrd_chlg_id'), period => param('period'), }; session list_hash => $input_hash; }; #re-request the page and display list_hash ??
2015-09-21 13:20 GMT-05:00 Andrew Beverley <andy@andybev.com>:
On Mon, 2015-09-21 at 13:09 -0500, Richard Reina wrote:
I have learned how to display variables in template toolkit with <% varname %>. However, these variables are being named from withing my dancer app and displayed on the template. Is there a way to display variables that a user is entering as they are entering it.
Not as part of TT - that all happens server side.
So that if I have a menu like form where a user can pick several items and see them each added one by one in a list format before pressing a second submit button that submits his entire lists of entries? It would be a bit like a shopping cart but instead of the items being put in the cart they are displayed right there in the form as they are added.
In which case you have 2 options:
1. Process it client-side with javascript (not recommended) 2. Make each "addition" a new request, and store server-side
You could also do a combination with AJAX-type calls, which is probably the best "modern" way of doing it, although it will be more complicated than option 2.
Andy
I have gone the with option 2. Basically I have two forms in the template. Form 1 lets the user add an item. Form 2 keeps a running tally of the items thus far added. What I can't figure out is how to make dancer differentiate between the two forms so that it knows that the user is done adding items and wants to check out so to speak he can hit the submit button of Form 2 to save all his submissions. Both forms have submit buttons but I am not sure how to make the POST route understand that the user is done with the form so that I can in turn make it save the data. Thanks for any ideas.
"Richard" == Richard Reina <gatorreina@gmail.com> writes:
Richard> 2015-09-21 13:20 GMT-05:00 Andrew Beverley Richard> <andy@andybev.com>: Richard> On Mon, 2015-09-21 at 13:09 -0500, Richard Reina wrote:
I have learned how to display variables in template toolkit with <% varname %>. However, these variables are being named from withing my dancer app and displayed on the template. Is there a way to display variables that a user is entering as they are entering it.
Richard> Not as part of TT - that all happens server side.
So that if I have a menu like form where a user can pick several items and see them each added one by one in a list format before pressing a second submit button that submits his entire lists of entries? It would be a bit like a shopping cart but instead of the items being put in the cart they are displayed right there in the form as they are added.
Richard> In which case you have 2 options: Richard> 1. Process it client-side with javascript (not recommended) Richard> 2. Make each "addition" a new request, and store server-side Richard> You could also do a combination with AJAX-type calls, which Richard> is probably the best "modern" way of doing it, although it Richard> will be more complicated than option 2. Richard> Andy Richard> I have gone the with option 2. Basically I have two forms in Richard> the template. Form 1 lets the user add an item. Form 2 keeps Richard> a running tally of the items thus far added. What I can't Richard> figure out is how to make dancer differentiate between the Richard> two forms so that it knows that the user is done adding items Richard> and wants to check out so to speak he can hit the submit Richard> button of Form 2 to save all his submissions. Both forms have Richard> submit buttons but I am not sure how to make the POST route Richard> understand that the user is done with the form so that I can Richard> in turn make it save the data. Umm... each form has it's own POST target? Or instead of two forms, you keep the running totals in DB with the keybeing the sessionID for that session. When they click on the main "submit" button, it just does a call to the page which totals it all up and presents things for final submission. So you'd just one form, which is for entering things. And then a seperate javascript button which calls in to do the final wrap up. Does this make sense? Sorry I don't have example code... John
Umm... each form has it's own POST target? Or instead of two forms, you keep the running totals in DB with the keybeing the sessionID for that session. When they click on the main "submit" button, it just does a call to the page which totals it all up and presents things for final submission.
So you'd just one form, which is for entering things. And then a seperate javascript button which calls in to do the final wrap up.
Does this make sense? Sorry I don't have example code...
John
Hi John, Yes that make sense but I guess what I am not clear on is how do I distinguish between the two submissions so that the post route knows that the user is done and to take further action? You mentioned as JavaScript button but how does such a button let the POST route know that the user is done? Sorry if I am not following something that should be obvious.
On Thu, 2015-10-01 at 16:10 -0500, Richard Reina wrote:
Both forms have submit buttons but I am not sure how to make the POST route understand that the user is done with the form so that I can in turn make it save the data.
You can differentiate between submit buttons by checking for the name of the submitted button, just like any other control on the form. If I've understood correctly, then I'd just have the one form, and use different submit button names. Andy
2015-10-01 17:33 GMT-05:00 Andrew Beverley <andy@andybev.com>:
On Thu, 2015-10-01 at 16:10 -0500, Richard Reina wrote:
Both forms have submit buttons but I am not sure how to make the POST route understand that the user is done with the form so that I can in turn make it save the data.
You can differentiate between submit buttons by checking for the name of the submitted button, just like any other control on the form.
If I've understood correctly, then I'd just have the one form, and use different submit button names.
Andy
So provided that I have named one button with name="add_entries" and the second name="submit_entries" could i just do the following in my dancer app: post '/entries_form' => sub { if (defined param('add_entries')) { # the source of this submission was the add_entries button # qualify and summarize addition } elsif (defined param('submit_entries')) { }
---------- Forwarded message ---------- From: Richard Reina <gatorreina@gmail.com> Date: 2015-10-02 8:36 GMT-05:00 Subject: Re: [dancer-users] Template Toolkit Help To: Perl Dancer users mailing list <dancer-users@dancer.pm> 2015-10-01 17:33 GMT-05:00 Andrew Beverley <andy@andybev.com>:
On Thu, 2015-10-01 at 16:10 -0500, Richard Reina wrote:
Both forms have submit buttons but I am not sure how to make the POST route understand that the user is done with the form so that I can in turn make it save the data.
You can differentiate between submit buttons by checking for the name of the submitted button, just like any other control on the form.
If I've understood correctly, then I'd just have the one form, and use different submit button names.
Andy
Sent before I was finished. Gmail needs to take the send button out of the tab index!!! So provided that I have named one button with name="add_entries" and the second name="submit_entries" could i just do the following in my dancer app? post '/entries_form' => sub { if (defined param('add_entries')) { # the source of this submission was the add_entries button # qualify and summarize addition redirect '/entries_form'; } elsif (defined param('submit_entries')) { # update submission to make them final }
On Fri, 2015-10-02 at 08:40 -0500, Richard Reina wrote:
So provided that I have named one button with name="add_entries" and the second name="submit_entries" could i just do the following in my dancer app?
post '/entries_form' => sub {
if (defined param('add_entries')) { # the source of this submission was the add_entries button
# qualify and summarize addition redirect '/entries_form';
} elsif (defined param('submit_entries')) {
# update submission to make them final }
Yes, exactly that. As an aside, you can lose "defined" (might make the code a little more readable), as long as you have a value for the submit button. Andy
2015-10-01 17:33 GMT-05:00 Andrew Beverley <andy@andybev.com>:
On Thu, 2015-10-01 at 16:10 -0500, Richard Reina wrote:
Both forms have submit buttons but I am not sure how to make the POST route understand that the user is done with the form so that I can in turn make it save the data.
You can differentiate between submit buttons by checking for the name of the submitted button, just like any other control on the form.
If I've understood correctly, then I'd just have the one form, and use different submit button names.
Andy
Hi Andy, The only thing with the approach of two submit buttons is that the second submit button triggers the required fields that are meant for the first submit button and thus don't allow the submission. Would you happen to know a way around this? Thanks
I use an onClick function (an event handler would probably be better) for buttons rather than the default behavior. In my case I use it to pre-process the data so it is more easily managed by Dancer2. On 10/6/2015 8:46 AM, Richard Reina wrote:
2015-10-01 17:33 GMT-05:00 Andrew Beverley <andy@andybev.com <mailto:andy@andybev.com>>:
On Thu, 2015-10-01 at 16:10 -0500, Richard Reina wrote: > Both forms have submit buttons but I am not sure how to make the POST > route understand that the user is done with the form so that I can in > turn make it save the data.
You can differentiate between submit buttons by checking for the name of the submitted button, just like any other control on the form.
If I've understood correctly, then I'd just have the one form, and use different submit button names.
Andy
Hi Andy,
The only thing with the approach of two submit buttons is that the second submit button triggers the required fields that are meant for the first submit button and thus don't allow the submission. Would you happen to know a way around this?
Thanks
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
2015-10-06 9:58 GMT-05:00 John McDermott, CPLP <jjm@jkintl.com>:
I use an onClick function (an event handler would probably be better) for buttons rather than the default behavior. In my case I use it to pre-process the data so it is more easily managed by Dancer2.
I ended up separating it into two different forms -- one for each submit button. Thanks for the onclick idea though.
On Tue, 2015-10-06 at 09:46 -0500, Richard Reina wrote:
If I've understood correctly, then I'd just have the one form, and use different submit button names.
The only thing with the approach of two submit buttons is that the second submit button triggers the required fields that are meant for the first submit button and thus don't allow the submission. Would you happen to know a way around this?
Surely that doesn't matter and you can just ignore those fields? if (param 'submit1') { my $value1 = param 'value1'; } elsif (param 'submit2') { ... # process second submission }
2015-10-06 10:13 GMT-05:00 Andrew Beverley <andy@andybev.com>:
On Tue, 2015-10-06 at 09:46 -0500, Richard Reina wrote:
If I've understood correctly, then I'd just have the one form, and use different submit button names.
The only thing with the approach of two submit buttons is that the second submit button triggers the required fields that are meant for the first submit button and thus don't allow the submission. Would you happen to know a way around this?
Surely that doesn't matter and you can just ignore those fields?
if (param 'submit1') { my $value1 = param 'value1'; } elsif (param 'submit2') { ... # process second submission }
Andy, Thanks for the help. I think just for my one quirky reasons I am going to use two forms in the template. Hope that an okay way to do it. Let me know if you think it could be problematic. Thanks again.
On Tue, 2015-10-06 at 12:44 -0500, Richard Reina wrote:
Thanks for the help. I think just for my one quirky reasons I am going to use two forms in the template. Hope that an okay way to do it. Let me know if you think it could be problematic.
TBH, that makes sense, if it is 2 separate sets of data submission. It was just a suggestion if it made it easier for your particular case. Andy
Like this? http://www.developergeekresources.com/examples/javascript/javascript-listbox... --john On 9/21/2015 12:09 PM, Richard Reina wrote:
I have learned how to display variables in template toolkit with <% varname %>. However, these variables are being named from withing my dancer app and displayed on the template. Is there a way to display variables that a user is entering as they are entering it. So that if I have a menu like form where a user can pick several items and see them each added one by one in a list format before pressing a second submit button that submits his entire lists of entries? It would be a bit like a shopping cart but instead of the items being put in the cart they are displayed right there in the form as they are added.
Thanks for any ideas.
Richard
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
-- John J. McDermott, CPLP Learning and Performance Consultant jjm at jkintl.com 575/737-8556 Check out my security blog posts <http://cybersecurity.learningtree.com> Add an A for the Arts To STEM and get STEAM and a strong engine to move forward.
Actually the user would have to make add an attribute first. Something like: Item Size 12 s Add Button 7 s Add Button 2015-09-21 13:35 GMT-05:00 John J. McDermott, CPLP <jjm@jkintl.com>:
Like this? http://www.developergeekresources.com/examples/javascript/javascript-listbox... --john
On 9/21/2015 12:09 PM, Richard Reina wrote:
I have learned how to display variables in template toolkit with <% varname %>. However, these variables are being named from withing my dancer app and displayed on the template. Is there a way to display variables that a user is entering as they are entering it. So that if I have a menu like form where a user can pick several items and see them each added one by one in a list format before pressing a second submit button that submits his entire lists of entries? It would be a bit like a shopping cart but instead of the items being put in the cart they are displayed right there in the form as they are added.
Thanks for any ideas.
Richard
_______________________________________________ dancer-users mailing listdancer-users@dancer.pmhttp://lists.preshweb.co.uk/mailman/listinfo/dancer-users
-- John J. McDermott, CPLP Learning and Performance Consultant jjm at jkintl.com 575/737-8556 Check out my security blog posts <http://cybersecurity.learningtree.com> Add an A for the Arts To STEM and get STEAM and a strong engine to move forward.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Since you have two data items and a button, I'd probably make a form for each pair, make the button have an onClick function that adds the items to a list, and then an overall submit button to do the submit. Or use a list like the example I posted earlier and have each pair in the list, if it wasn't a big list. So 12s 12l 7s 7l and so forth. On 9/21/2015 1:41 PM, Richard Reina wrote:
Actually the user would have to make add an attribute first. Something like:
Item Size 12 s Add Button 7 s Add Button
2015-09-21 13:35 GMT-05:00 John J. McDermott, CPLP <jjm@jkintl.com <mailto:jjm@jkintl.com>>:
Like this? http://www.developergeekresources.com/examples/javascript/javascript-listbox... --john
On 9/21/2015 12:09 PM, Richard Reina wrote:
I have learned how to display variables in template toolkit with <% varname %>. However, these variables are being named from withing my dancer app and displayed on the template. Is there a way to display variables that a user is entering as they are entering it. So that if I have a menu like form where a user can pick several items and see them each added one by one in a list format before pressing a second submit button that submits his entire lists of entries? It would be a bit like a shopping cart but instead of the items being put in the cart they are displayed right there in the form as they are added.
Thanks for any ideas.
Richard
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm <mailto:dancer-users@dancer.pm> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
-- John J. McDermott, CPLP Learning and Performance Consultant jjm at jkintl.com <http://jkintl.com> 575/737-8556 <tel:575%2F737-8556> Check out my security blog posts <http://cybersecurity.learningtree.com> Add an A for the Arts To STEM and get STEAM and a strong engine to move forward.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm <mailto:dancer-users@dancer.pm> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
-- John J. McDermott, CPLP Learning and Performance Consultant jjm at jkintl.com 575/737-8556 Check out my security blog posts Add an A for the Arts To STEM and get STEAM and a strong engine to move forward.
participants (5)
-
Andrew Beverley -
John J. McDermott, CPLP -
John McDermott, CPLP -
John Stoffel -
Richard Reina