Ad

Express/pug Loop To Generate Table With Form Per Row

- 1 answer

Im just starting out with node.js/express/pug but i cannot get it to produce a form per row.

i have this template

mixin listentry(alternate,name,exposureTime,manufactor,usecount,lastused)
tr()
    | <form action='' method='post'>
    td()
        input(type='text',name='name',readonly,class='w100',value=name)
    td()
        input(type='number',name='exposureTime',class='w75',value=exposureTime)
    td()
        input(type='text',name='manufactor',class='w100',value=manufactor)
    if usecount == ""
        td()
        td() never
    else
        td() #{usecount}
        td() #{lastused}
    td() Delete Update
    | </form>


- var alternate = false;
each profile,name in profiles
    +listentry(alternate,name,profile.exposureTime,profile.manufactor,profile.usecount,profile.lastused)
    - var alternate = !alternate;

this produces:

<tr>
   <form>....</form>
   <td>.... ect

but i expected it to make

<tr>
   <form.....
   <td>.... ect
   </form>

What am i doing wrong?

No matter what i try, i cannot get it to produce a form containing the td's of a row, hence i dont the input into the form.

I and i try dont wish to have one big form containing all the rows.

edit: new version with form() but still do not produce the desired output

mixin listentry(alternate,name,exposureTime,manufactor,usecount,lastused)
   tr()
     form(action='', method='post')
        td()
            input(type='text',name='name',readonly,class='w100',value=name)
        td()
            input(type='number',name='exposureTime',class='w75',value=exposureTime)
        td()
            input(type='text',name='manufactor',class='w100',value=manufactor)
        if usecount == ""
            td()
            td() never
        else
            td() #{usecount}
            td() #{lastused}
        td() Delete Update
Ad

Answer

Apperently Sean is right, you cannot have a form in per row any more.

so solution is to use jquery

Create a HTML table where each TR is a FORM

Ad
source: stackoverflow.com
Ad