Simulates the public account background voting management function. You can add multiple questions dynamically. Each question has two options by default. You can also add multiple questions dynamically. The dynamic addition function has been implemented through JS, but the value of the problem option cannot be obtained in PHP. The html of a single option is as follows {code...} Because every...
Simulates the public account background voting management function.
You can add multiple questions dynamically. Each question has two options by default. You can also add multiple questions dynamically. The dynamic addition function has been implemented through JS, but the value of the problem option cannot be obtained in PHP. The html of a single option is as follows:
*
Because there are options for each problem, ifname="options[]"In this way, you cannot know which problem the option belongs.
How can I set it correctly?inputElementnameAttribute.
Reply content:
Simulates the public account background voting management function.
You can add multiple questions dynamically. Each question has two options by default. You can also add multiple questions dynamically. The dynamic addition function has been implemented through JS, but the value of the problem option cannot be obtained in PHP. The html of a single option is as follows:
*
Because there are options for each problem, ifname="options[]"In this way, you cannot know which problem the option belongs.
How can I set it correctly?inputElementnameAttribute.
There are too many open-source codes to solve this problem. The basic idea is to count the number of existing inputs before adding them, then count + 1 sets the array name = "options [" + count + "]" for name.
Paste several existing open source codes
Http://jsfiddle.net/jaredwilli/tzpg4/4/
Http://bootsnipp.com/snippets/featured/dynamic-form-fields-add-amp-remove
Question 1 name = "question [0]" option name = "answer [0] [0]" name = "answer [0] [1]" question 2 name = "question [1] "option name =" answer [1] [0] "name =" answer [1] [1]"
By adding a hidden field to store the problem label, the code of the dynamic output problem segment is solved. However, this is only the addition phase, and later modifications may be more troublesome. Thank you.