我创建了一个包含多个同名字段的表单:
<form ... >
<input type=text name="problem" value="problem1" />
<input type=text name="question" value="question1" />
<input type=text name="answer" value="answer1" />
<input type=text name="problem" value="problem2" />
<input type=text name="question" value="question1" />
<input type=text name="answer" value="answer1" />
<input type=text name="question" value="question2" />
<input type=text name="answer" value="answer1" />
<input type=text name="answer" value="answer2" />
...
<input type=hidden name="jsonString" value="" />
<input type=submit value="Send" />
</form>
这些字段可以通过javascript动态添加/删除
我想在隐藏字段中放入一个字符串(使用 JSON.strinfigy)并在提交之前通过表单传递:
{
problem: [
{
name: problem 1,
question: [
{
name: question 1,
answer: [
name:answer1
]
}
]
},
{
name: problem 2,
question: [
{
name: question 1,
answer: [
name:answer1
]
},
{
name: question 2,
answer: [
name:answer1,
name:answer2
]
}
]
}
]
}
有什么想法吗?谢谢
抢