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 9284081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:47:57+00:00 2026-06-18T18:47:57+00:00

For each question, I want to compile an if statement where by checking through

  • 0

For each question, I want to compile an if statement where by checking through each question if the .ReplyType text input equals Single, then the user can only select a single checkbox button option, otherwise if the .ReplyType text input equals Multiple, then the user can select multiple checkbox button options.

My question is how to implement this if a single button or multiple buttons are selected depending on the .ReplyType text input? Is it better in PHP or JavaScript?

Below is relevant code:

<form action='results.php' method='post' id='exam'>

    <?php

//COMPILE OPTION BUTTONS

    function ExpandOptionType($option) { 
        $options = explode('-', $option);
        if(count($options) > 1) {
            $start = array_shift($options);
            $end = array_shift($options);
            do {
                $options[] = $start;
            }while(++$start <= $end);
         }
         else{
            $options = explode(' or ', $option);
         }

         foreach($options as $indivOption) {
             echo '<div class="ck-button"><label class="fixedLabelCheckbox"><input type="checkbox" name="options[]" id="option-' . $indivOption . '" value="' . $indivOption . '" /><span>' . $indivOption . '</span></label></div>';
         }


    }


    foreach ($arrQuestionId as $key=>$question) {

    ?>

    <div class="queWrap">

//DISPLAY QUESTION NUMBER FOR EACH QUESTION
    <p><?php echo htmlspecialchars($arrQuestionNo[$key]);?></p>

//DISPLAY OPTION CHECKBOX BUTTONS FOR EACH QUESTION
    <?php echo ExpandOptionType(htmlspecialchars($arrOptionType[$key])); ?>

//DISPLAY REPLY TYPE TEXT INPUT FOR EACH QUESTION
    <p>Reply Type: <input type='text' class='replyType' name='replytype' value='<?php echo htmlspecialchars($arrReplyType[$key]); ?>' /></p>



    </div>


    <?php

    }

    ?>
  • 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-06-18T18:47:59+00:00Added an answer on June 18, 2026 at 6:47 pm

    You should do both, JavaScript and PHP implementation.

    JavaScript is better for the user to get a response before submitting the form.

    PHP is important, because JavaScript validation can be bypassed (just deactivate JavaScript) in this case your PHP should still validate that you get consistent data.

    Anyway: Use radio-buttons for single-select and checkboxes for multi-select. Not that it’s already implemented in every browser and meant to be used that way, most users have already learned this behavious and won’t be surprised by your JavaScript (or PHP) validation.

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

Sidebar

Related Questions

I want to show pop up of question with it's options. Each question have
My code below is supposed to display each question ($_POST[questionText]). For each question, it
I'm trying to push just the contents of the txt attribute in each question
Jquery Each Json Values Issue This question is similar to above, but not the
My question is to retrieve a shop who sell each item at more than
A quick question on best practice for handling images in a PHP/MySQL CMS. Each
(Newbie DBUnit question Alert!) It appears that DBUnit for each table 'deletes all the
I recentely asked a question about using an apply function over two lists. Each
Looks like this question has been asked thousand times already, but each person's configuration
I have a question about if - else structure in a batch file. Each

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.