javascriptnode.jsexpresspugjade4j

submit post form values from jade to node js


I have such a form on my jade template

  form(action='/scheduler/save/' + project.Id, method='post')
                div.form-group
                    label.control-label.col-md-2 RecurringPattern
                    div.col-md-10
                        div#RecurringPatternControl
                div.form-group
                    label.control-label.col-md-2 StartDate
                    div.col-md-3
                        //input#StartDate.form-control
                        input(id='StartDate', class='form-control', value='#{project.StartDate} ', enctype="application/x-www-form-urlencoded")
                div.form-group
                    div.col-md-offset-2.col-md-10
                        input(type="submit", value="Save").btn.btn-lg.btn-success

and I want StartDate from input value in node js, I gotdiv#RecurringPatternControl from req.body but StartDate I can't get(( How can I fix that?


Solution

  • I think you need a "name" attribute in your input to be able to retrieve it later on. Just try adding something like

    input(id='StartDate', name='startDate', class='form-control', value='#{project.StartDate} ', enctype="application/x-www-form-urlencoded"
    

    It should work, if not try reviewing the whole POST header to see what's actually happening (and may be post it here if necessary)

    Hope this helps !