jeudi 22 juin 2017

get checkbox checked value in pug and node.js

how to get the checkbox value if is checked, to redirected to this (href="/player/edit/:id") and (href="/player/delete/: id") , and receive the value of the player id for the edit and delete operations

It was not necessary to put the remaining code, such as app.js where it contains the server, the routes and the request-handlers and the connection with MySQL

this template editPlayer.pug is redirected to (href="/player/edit/:id") that receive player id and the doubt is how to get?

extends main

block content
    form(action="/editPlayer/:id", method="post")
      br
      label(for="name") Name:
      br
      input(id="name", name="name", type="text")
      br
      input(id="id",name="id",type="hidden", value="id")
      br
      button(type="reset") Reset
      button(type="submit") Save

this templates player.pug is to get the value of checkbox if is checked and redirect to href for button edit and delete player by id?

extends main

block content
   form(action="/player", method="get")
     table(
       thead
        tr
         th
          |ID
        th
         |Name
       tbody
         each player in player
           tr
            td
             input(type="checkbox", id=player.player_id, 
                     name=player.player_id, value=player.player_id)
            td
             |#{player.player_id}                                 
    div
      br
      a(href="/player/edit/:id")
          button(type="button") Edit
      a(href="/player/:id")
          button(type="button") Delete

any suggestion?




Aucun commentaire:

Enregistrer un commentaire