Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4623162
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:56:48+00:00 2026-05-22T02:56:48+00:00

I have this form that I need to submit few question with some hidden

  • 0

I have this form that I need to submit few question with some hidden values and link them all together.

I currently append name with the ID of the question and then add _ then the number of answers.

<form>
    <span>1:Question goes here </span>
    <input type=hidden name=t_1 value=10>
    <input type=hidden name=f_1 value=20>
    <input type=checkbox name=a1_1>value1
    <input type=checkbox name=a1_2>value2
    <input type=checkbox name=a1_3>value3
    <span>2:Question goes here </span>
    <input type=hidden name=t_2 value=40>
    <input type=hidden name=f_2 value=20>
    <select name=a2_1>
        <option>blah</option>
        <option>etc</option>
    </select>
</form>

On the server side, I explode the fields submitted and put them together:

foreach ($_POST as $var => $val) {
    switch ($var[0]) {
        case "a" :
            $b = substr($var, 1); // remove first char to get number following
            $pos = strpos($b, "_");
            if ($pos !== false) {
                $i = explode("_", $b); // separating question number from choice number (for multi select questions)
                $answer[$i[0]][] = $val;
                break;
            }
            else {
                $answer[$b][] = $val;
                break;
            }
        case "t" :
            $b = substr($var, 1);
            $target[$b] = $val;
            break;
    }
}

Is there a better way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:56:49+00:00Added an answer on May 22, 2026 at 2:56 am

    you can name your tags in the following manner:

    <input name="question[1][answer]" type="text" value="someValue" />
    

    this will create array for your questions and you can itterate through them, without needing to explode or substring anything.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this java servlet that grabs information from a form, I need to
I have this function to edit all fields that come from the form and
I have a form that I need to submit automatically... (the fields are already
I basically have a form inside of Flash that I need to submit to
I have this form that is using data-defaults and I need to be sure
So this is kind of complicated. I have a form that I need to
i need to have a form when you press the main submit button all
Okay, so I have this form that is set to preload a DB record
I have a form that and after the user fills in this form, I
Please have a look at this form that I am trying to design with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.