PHP Dynamic input box for input values

Source: Internet
Author: User

Imitate the public number backstage voting management function.
You can add multiple issues dynamically, each with two options under the default, or add multiple items on the fly. The dynamic add function has been implemented via JS, but the value of the problem option cannot be obtained in PHP, the HTML of the individual option is as follows

*

Because there are options under each question, you name="options[]" won't know which problem that option belongs to.

How do I set input the attributes of an element correctly? name

Reply content:

Imitate the public number backstage voting management function.
You can add multiple issues dynamically, each with two options under the default, or add multiple items on the fly. The dynamic add function has been implemented via JS, but the value of the problem option cannot be obtained in PHP, the HTML of the individual option is as follows

*

Because there are options under each question, you name="options[]" won't know which problem that option belongs to.

How do I set input the attributes of an element correctly? name

There are too many open source code to solve such a problem, the basic idea is to add a count of the current number of input, and then count+1 for the name array name= "options[" +count+ "]"

Post several existing open source code

http://jsfiddle.net/jaredwilli/tzpg4/4/

Http://bootsnipp.com/snippets/featured/dynamic-form-fields-add-amp-remove

问题1name="question[0]"选项name="answer[0][0]" name="answer[0][1]"问题2name="question[1]"选项name="answer[1][0]" name="answer[1][1]"

The code for the dynamic output problem segment is resolved by adding a hidden field to store the problem label. However, this is only an add-on phase, and later revisions can be more cumbersome. Thank you here.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.