Use the POST method to obtain information about whether the radio button is selected.

Source: Internet
Author: User
Tags xslt
Problem description:

I recently submitted a single-choice question form with a total of 90 questions, five options for each question, and five radio buttons. Because it is a single-choice question, the five radio buttons of each question are used as a group and the same name (question number of the question) is used. Each option is assigned a result value, 5 ). When submitting a form, you need to obtain the option selected for each question based on the user's choice, save the result value of this option to an array or string, and submit it to the database,.

Implementation Scheme:

Use an XML file to save the question data and use an XSLT file to generate a webpage display format. In An XSLT file, when you need to output a radio button, define a radio button, the Code is as follows (taking Question 1st as an example ):

<Input type = "radio", name = "1", value = "3">
Option 3
</Input>

In this way, the XSLT file defines 450 options for all 90 questions. The name attribute of each of the five options is the same, which is the question number. The Value Attribute of each option represents the result value of the option.

After the form is submitted, the POST method is used to obtain the form information. The Code is as follows (taking the option result of obtaining question 1st as an example ):

Int result = request. Form ("1 ");

When you request. Form a radio button, the input parameter is the name attribute of the radio button to be obtained. Only the selected radio button is returned. The returned value is the value attribute of the radio button. Therefore, in the five radio buttons with name 1, the selected value attribute value is returned. That is, the result stores the option result values of the user for question 1st.

And so on, you can obtain the option result values selected by all 90 questions.

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.