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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:05:36+00:00 2026-06-01T06:05:36+00:00

I have a Jquery code that is following: var selectedQuestions = $(#SelectedQuestions); var selectedCustomQuestions

  • 0

I have a Jquery code that is following:

var selectedQuestions = $("#SelectedQuestions");
var selectedCustomQuestions = $("#SelectedCustomQuestions");
var currentIds = new Array();
var currentText = new Array();

$("#CustomPickedTable td[data-question-id]").each(function () {
    var clickedId = $(this).attr("data-question-id");
    currentIds.push(clickedId);

    $('#CustomPickedTable tr').each(function () {
        var ClickedText= $(this).find("td[data-attr-id]:first").html();
        currentText.push(ClickedText);
    });
});

selectedCustomQuestions.val(currentText.join("|"));
selectedQuestions.val(currentIds.join(","));

$("form").submit();
}

I have two types of TD in my table that is following:

<td data-question-id="7">test</td>

and

<td data-attr-id="5">test</td>

I want to be able to sort em into different hiddenfields these are my hiddenfields:

@Html.HiddenFor(model => model.SelectedCustomQuestions, new { @id = "SelectedCustomQuestions" }) 
@Html.HiddenFor(model => model.SelectedQuestions, new { @id = "SelectedQuestions" })

my Jquery code works when it comes to fill my array with CurrentIds but with currentText I get problems, if I have two <td data-attr-id="5">test</td> in my table they get duplicated in my array list and my array lenght is 7-10 which is weird. The CurrentText should only have 2 length and its not. How can I fix this?

Example on the problem.

I have this following inside my table:

<td data-attr-id="5">aaaa</td>
<td data-attr-id="5">ddd</td>
<td data-question-id="5">test</td>
<td data-question-id="15">test</td>

and this is what happens when i debug my jquery code

example

Thanks in advance!

  • 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-01T06:05:38+00:00Added an answer on June 1, 2026 at 6:05 am

    Just try this one with slight modification.

    var selectedQuestions = $("#SelectedQuestions");
        var selectedCustomQuestions = $("#SelectedCustomQuestions");
        var currentIds = new Array();
        var currentText = new Array();
    
        $("#CustomPickedTable td[data-question-id]").each(function () {
            var clickedId = $(this).attr("data-question-id");
            currentIds.push(clickedId);
        });
        $('#CustomPickedTable td[data-attr-id]').each(function () {
            var ClickedText = $(this).html();
            currentText.push(ClickedText);
        });
    
        selectedCustomQuestions.val(currentText.join("|"));
        selectedQuestions.val(currentIds.join(","));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that shows a jquery ui dialog form with data
Let's assume that we have simple jQuery code like the following: var $document =
I have the following jQuery code: $('.save').submit(function(e){ var formElement = $(this); var data =
I have the following jQuery Code: $(#menu span).click(function() { var url = this.getAttribute(data-url); var
I have the following block of jQuery code that I'm using to copy some
I have the following JQUERY code that I'm expecting to return 3 json results
I have the following JQuery code that processes a GET request upon page load:
I have the following JQuery code that is giving me some problems. The first
I have a jQuery slideshow code that works fine with the following HTML structure:
For example I have following jQuery code: var div1 = $(divs).next(); How do I

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.