Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^15: Need to know the process to implement perl script into web application server.

by choroba (Cardinal)
on May 24, 2021 at 19:16 UTC ( [id://11132987]=note: print w/replies, xml ) Need Help??


in reply to Re^14: Need to know the process to implement perl script into web application server.
in thread Need to know the process to implement perl script into web application server.

You defined two "post" routes for '/'. How should Perl know which one to call? It also seems your "result" template handles totally different sets of keys. It might be easier to define two different templates.

It's not clear what your form is supposed to do. What if the fields related to the first submit button are filled, but the the second submit button is clicked? BTW, you can use JavaScript to disable the fields under the non-selected radio button. That's not Perl related at all.

Start from a simple example (haven't I already told you?). Google your questions first before asking here. You can have multiple submit buttons, but you need to name them to distinguish which one was clicked. This either is not a Perl related issue.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
  • Comment on Re^15: Need to know the process to implement perl script into web application server.
  • Download Code

Replies are listed 'Best First'.
Re^16: Need to know the process to implement perl script into web application server.
by chandantul (Scribe) on Jul 15, 2021 at 02:05 UTC

    Hi, I have made the modification in query.tt but i was unable to distinguish them in webapp.pm. Maybe i need correct syntax. Please check below my query.tt and webapp.pm . How can i retrieve submit button name and distinguish them in my webapp.pm?

    <form id="f1" method="post" action="/"> <style> body { background-color: #ABBAEA; } div { height: 200px; background-color: #FBD603; } </style> <body> <div> <input type="radio" name="OKTAUsersList"> <label for="OKTAUsersList">OKTA-Users-List</label> <label for="Email">Recipient Email</label> <input id="email" name="Email"> <input type="submit" name="Users-list" value="Users-list" /> </div> <div> <input type="radio" name="OKTAAppsList"> <label for="OKTAAppsList">OKTA-Apps-List</label> <label for="Email">Recipient Email</label> <input id="email" name="Email"> <input type="submit" name="Apps-list" value="Apps" /> </div> </body> </form>

    webapp.pm

    post '/' => sub { my $_POST = "post"; if (body_parameters->get('name') eq 'Users-list' ) { $id = route_parameters->get('site_id'); my $site_id2 = params->{$id}; @access_token = client2($site_id2)->get_access_token($p); print Dumper \@access_token; } };
      webapp.pm
      package webapp; use Dancer2; my %common = (title => 'webapp'); get '/' => sub { template index => { %common }; }; post '/' => sub { if (body_parameters->get('Users-list') eq 'Users-list' ) { template index => { %common, button => 'Users-list' } } elsif (body_parameters->get('Apps-list') eq 'Apps') { template index => { %common, button => 'Apps-list' } } }; true;
      index.tt
      [% IF button %] <p>You pressed [% button %].</p> [% ELSE %] <form id="f1" method="post" action="/"> <div> <input type="radio" name="OKTAUsersList"> <label for="OKTAUsersList">OKTA-Users-List</label> <label for="Email">Recipient Email</label> <input id="email" name="Email"> <input type="submit" name="Users-list" value="Users-list" /> </div> <div> <input type="radio" name="OKTAAppsList"> <label for="OKTAAppsList">OKTA-Apps-List</label> <label for="Email">Recipient Email</label> <input id="email" name="Email"> <input type="submit" name="Apps-list" value="Apps" /> </div> </form> [% END %]
      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      A reply falls below the community's threshold of quality. You may see it by logging in.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11132987]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-20 06:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found