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

  • SEARCH
  • Home
  • 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 9257941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:16:10+00:00 2026-06-18T12:16:10+00:00

The code below is a dynamic way of displaying each option as checkbox buttons

  • 0

The code below is a dynamic way of displaying each option as checkbox buttons for each question:

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


            }


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

            ?>

            <p><?php echo ExpandOptionType(htmlspecialchars($arrOptionType[$key])); ?></p>

    <p><input type='text' class='questionIds' name='questionids' value='<?php echo htmlspecialchars($arrQuestionId[$key]); ?>' /></p>

    <p><input type='text' class='responseTime' name='responsetime' value='00:00:00' /></p>

    <p><input type='text' class='mouseClick' name='mouseclick' value='0' /></p>

}

Now below I 2 text inputs which are also in the foreach loop, one for response time and other is for counting mouse click:

<p><input type='text' class='responseTime' name='responsetime' value='00:00:00' /></p>

<p><input type='text' class='mouseClick' name='mouseclick' value='0' /></p>

Now this is my questions:

  1. The response time text input contains a count up timer. What I want is that if the first button checkbox is clicked in a question, the question’s response timer should stop. This is so we know how long it took the user to respond answering a particular question

  2. The mouse click text starts with 0 and what I want this text input to do is for every button checkbox that is clicked in a question, the question’s mouse click text input counts up the amount of clicks so we know how many clicks on the question’s options the user has compiled.

How can the above be achieved?

Below is a jsfiddle showing sample code of what it looks like for one question:

http://jsfiddle.net/zAFND/630/

UPDATE:

Source code showing multiple questions example:

QUESTION 1:

<p>
<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-A" value="A" />
<span>A</span>
</label>
</div>

<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-B" value="B" />
<span>B</span>
</label>
</div>

<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-C" value="C" />
<span>C</span>
</label>
</div>

<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-D" value="D" />
<span>D</span>
</label>
</div>

<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-E" value="E" />
<span>E</span>
</label>
</div>

<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-F" value="F" />
<span>F</span>
</label>
</div>

</p>

<p><input type='text' class='questionIds' name='questionids' value='73' /></p>


<p><input type='text' class='responseTime' name='responsetime' value='00:00:00' /></p>

<p><input type='text' class='mouseClick' name='mouseclick' value='0' /></p>



QUESTION 2:

<p>
<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-A" value="A" />
<span>A</span>
</label>
</div>

<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-B" value="B" />
<span>B</span>
</label>
</div>

<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-C" value="C" />
<span>C</span>
</label>
</div>

<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-D" value="D" />
<span>D</span>
</label>
</div>

<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-E" value="E" />
<span>E</span>
</label>
</div>

</p>

<p><input type='text' class='questionIds' name='questionids' value='74' /></p>


<p><input type='text' class='responseTime' name='responsetime' value='00:00:00' /></p>

<p><input type='text' class='mouseClick' name='mouseclick' value='0' /></p>
  • 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-18T12:16:12+00:00Added an answer on June 18, 2026 at 12:16 pm

    As you created a reference for setinterval that is good. Now you can remove the set interval on click event of first checkbox and add a click event on all checkbox to increase counter.

    That will be

    $(document).ready(function(){
    var checkBox=$('#ck-button').find('input');
    var responsetimer=//your interval function
    checkbox.filter(':first').bind('click',function(e){
     clearInterval(responsetimer);
    });
    checkbox.bind('click',function(e){
    $('.mouseClick').val(parseInt($('.mouseClick').val())+1);
    });
    });
    

    Well i am not sure about the question you want timer to be stopped at first button click or first time button clicked. If it is first time than dont use the first binding . keep clear interval in second binding itself.

    checkbox.bind('click',function(e){
     clearInterval(responsetimer);
     $('.mouseClick').val(parseInt($('.mouseClick').val())+1);
    });
    

    JS fiddle :http://jsfiddle.net/zAFND/631/
    for second option
    http://jsfiddle.net/zAFND/638/

    UPDATE
    if you want this for multiple question wrap each question with a div say <div class="queWrap"></div>

    Make a array refrence for your interval function so that it can be clear.

    Loop to each queWrap and start timer and assign events on checkbox.

    Check example for multiple question :http://jsfiddle.net/zAFND/640/

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

Sidebar

Related Questions

The below code works, I'm just curious if there is a dynamic way to
I am creating a dynamic array inside a function. The code (posted below) runs
I'm using this PHP code below to create dynamic xml files. ... $file_name =
given the code below dynamic e = new ExpandoObject(); var d = e as
Code below is working well as long as I have class ClassSameAssembly in same
Code below is used to save PostgreSql database backup from browser in Apache Mono
The code below simply didn't work. document.getElementById('files').addEventListener('change', handleFileSelect, false); reported by firebug that this
This code below allows me to find the word error in all my files
The code below fails on the line: Class.forName(oracle.jdbc.driver.OracleDriver); with the error: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver The
My code below gave a different length for the unsigned char pointer I expect.

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.