开发者

Pass 3 of the same thing to ExpressJS with a form

Say I have a form that I want users to be able to submit 3 of the same type of thing; for example: 3 categories. Is there a way to pass an a开发者_运维百科rray?

Something like: input(type: "text", name: "user[category]") 3 times in my form? It's probably something like name: "user[category[]]" but that's not working for me right now.


user[category][]. You can try it out using the repl.

var qs = require('qs');
qs.parse('user[category][]=cat1&user[category][]=cat2')
// { user: { category: [ 'cat1', 'cat2' ] } }

You can see the source of qs at their github page. By the way, I think you can only specify a list of string, not a list of object. Look at the unit tests for more examples.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜