I tried to get a value from a HTML table to Node JS. I tried like following,
HTML
<table class="table">
{{#images}}
<tr>
<td><a href="/deleteImage" class="btn btn-danger" title="Clear All">X</a><label value={{imgURL}} name="imageID">{{imgURL}}</label>
</td>
<td><img src={{imgURL}} alt="Mountain View" style="width:228px;height:340px"></td>
</tr>
{{/images}}
</table>
app.js
app.get('/deleteImage', function (req, res) {
images.removeImage(req.body.imageID, function (err, result) {
if (err) return res.json(err);
images.getImages(function (err, images) {
if (err) return res.json(err);
var msg = 'Deleted ' + result.affectedRows + ' rows.';
res.render('delete_image.html', {images: images, msg: msg});
});
});
});
I tried to read the imageID from the HTML like above. But It's undefined. How can I fix this.
Thanks in Advance!
/deleteImage?id=123. Then on your node server, you can get theid=123out of the URL. If you don't want to actually load a new web page when sending the request, then make the request an Ajax call.