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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:43:27+00:00 2026-05-12T11:43:27+00:00

I want to allow the user to click a start point and then click

  • 0

I want to allow the user to click a start point and then click an ending point and be able to manipulate various form elements between the two points that were selected.

The page is a table with numerous rows and each row contains the relevant information to manipulate/save an answer to the question in that row. Each row has a hidden input for the value, as well as Yes/No radio buttons, mainly for un-skilled users. The TD cell with the question allows the user to click or toggle between Yes,No,Empty. So basically I left the radio buttons on the page to show Yes/No and use a hidden field to store a value of (1,0,-1)

This is what I use to set the answer when the question cell is clicked.

    $(".question").bind("click dblclick", function(e) {

        var newClassName = "AnswerUnknown";

        var hiddenAnswerId = $(this).attr('id').replace("question", "answer");

        var answer = parseInt($("#" + hiddenAnswerId).val());

        var newValue;

        switch (answer) {
            case -1:
                newClassName = "AnswerCorrect";
                newValue = 1;
                $("#" + $(this).attr('id').replace("answer", "radioYes")).attr('checked', 'checked');
                $("#" + $(this).attr('id').replace("answer", "radioNo")).attr('checked', '');
                break;
            case 1:
                newClassName = "AnswerWrong";
                newValue = 0;
                $("#" + $(this).attr('id').replace("answer", "radioYes")).attr('checked', '');
                $("#" + $(this).attr('id').replace("answer", "radioNo")).attr('checked', 'checked');
                break;
            default:
                newClassName = "AnswerEmpty";
                newValue = -1;
                $("#" + $(this).attr('id').replace("answer", "radioYes")).attr('checked', '');
                $("#" + $(this).attr('id').replace("answer", "radioNo")).attr('checked', '');
        }
        $("#" + hiddenAnswerId).val(newValue);
        $(this).removeClass().addClass(newClassName);
    });

Now I want to allow the user to click a starting point and have that answer populate all the following question down to wherever they clicked on the second item. Could be 10 questions away, or 20 questions, it is an unknown variable. There may be a page with 130 questions on it, and 20 questions in a row may be “Yes”. As stated above each row has a “Question” cell and the cell before that is the item cell.

I know how to set the starting element and the ending element based on a jquery selector/function bound to a click/dblclick event listed below.

What I am not sure about is how to traverse the dom or select all the elements I need to manipulate between the two selected points on the page.

    var StartItem;
    var EndItem;

    $(".item").bind("click dblclick", function(e) {

        var StartClassName = "AnswerUnknown";
        var EndClassName = "AnswerUnknown";
        var StartAnswerId;
        var EndAnswerId;
        var StartAnswer;

        if (StartItem === undefined) {
            StartItem = this;
            StartAnswerId = $(this).attr('id').replace("item", "rs");
            StartAnswer = parseInt($("#" + StartAnswerId).val());
        }
        else {
            if (EndItem === undefined) {
                EndItem = this;
                EndAnswerId = $(this).attr('id').replace("item", "rs");
                EndAnswer = parseInt($("#" + EndAnswerId).val());
            }
        }


        if (StartItem == this) {
            $(this).removeClass().addClass(StartClassName);
        }

        if (EndItem == this) {
            $(this).removeClass().addClass(EndClassName);
        }
    });
  • 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-12T11:43:28+00:00Added an answer on May 12, 2026 at 11:43 am

    The best way IMHO is to do something like below. You can loop over the collection of elements with class name “item” and when you find your start element you can begin doing the processing that you described. Since you have ‘this’ you can take that id and do what you were doing in your question.click function.

            var counter = 0;
    
        // This will loop over each element with classname "item", so make sure you take that into account
                $('.item').each(function(i) {
            // function returns this, but you can see what index your on with 'i'
                    if (this == StartItem) {
                        // You can start processing rows
                        counter = 1;
                    }
                    else {
                        if (counter > 0) {
                            // Process rows/items after the first item above
                            counter = counter + 1;
                        }
                    }
                    if (this == EndItem) {
                        counter = 0
                        // Finish up processing if any
                        //Break out of each;
                    }
    
                });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't want to allow user to double click on my button. On the
I want to allow user to upload a file of txt ,doc or pdf
I want to allow user to enter only english alphabets and characters. How can
customers does not want to allow user to use back or forward button. Just
I am downloading PDF file in my application and want to allow user to
I want to allow a user to download an html file using a php
I want to allow the user to use lowercase or uppercase letters giving the
I want to allow a user to drag my Win32 window around only inside
I want to allow any user to create a category using a text field.
I want to open a WPF4/EF4 form in AddNew mode so the user can

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.