javascript - How to use <a> instead of a button on express.js post? -


i using handlebars templating engine , use buttons call app.post() on javascript file.

<form method="post" action="/smo_assessment"> <div class="container" id="div1">     <h3 id="header" align="center">request inventory</h3>     <h4 style="color: white">select id of request want make assesssment</h4>      <table>     <td>         <select class="form-control" style="width: 80px" name="requestid">             {{#each requests}}             <option>{{this.id}}</option>             {{/each}}         </select>     </td>     <td>         <button buttontype="submit" class="btn btn-default" id=btn1>make assessment</button>     </td>     </table> </form> 

however, since using bootstrap navbar, need use <a> tag instead of button in order navigate different page.

app.post('/smo_assessment', urlencodedparser, function(req, res){     connection.query('select * requests id=?', req.body.requestid, function(err, rows, fields){         if(err)             throw err;         else              selectedrequest = rows            res.render('smo_assessment', {assessmenttype, data: selectedrequest[0]});        });  }); 

try form.submit() javascript method:

<form id="theform" method="post" action="/smo_assessment">  <div class="container" id="div1">      <h3 id="header" align="center">request inventory</h3>      <h4 style="color: white">select id of request want make assesssment</h4>        <table>      <td>          <select class="form-control" style="width: 80px" name="requestid">              {{#each requests}}              <option>{{this.id}}</option>              {{/each}}          </select>      </td>      <td>          <a href="javascript:document.getelementbyid('theform').submit();" class="linksubmit" id="linkbtn1">make assessment</a>      </td>      </table>  </form>


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -