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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:33:49+00:00 2026-06-18T19:33:49+00:00

Each time the user clicks over a checkbox I add a couple of values

  • 0

Each time the user clicks over a checkbox I add a couple of values to a hidden input value.

Each checkbox stores 2 values and it looks like this:

<input type="checkbox" class="first" value="9598864;3">

Where the first value would be: 9598864 and the second: 3.

Currently I am adding data to the input in this way:

var currentValue = $('#myInput').val();
var text;

//adding the value to the input + separator "-"
if($(this).is(':checked')){
    $('#myInput').val(currentValue + "-" + $(this).val());
}

//erasing the value from the input + separator "-"
else{
    text = currentValue .replace("-" + $(this).val(), "");
    $('#myInput').val(text);
}

The result is something like this:

<input type="hidden" name="demo" value="-9582856;3-9598864;3" id="myInput">

Where i get an array of 2 elements each one with another 2 elements inside:

Element 1:

  • 9582856
  • 3

Element 2:

  • 9598864
  • 3

What I am doing now is processing the data on the server side (PHP) and exploding those strings by - and ; to get the desirable elements.

Is there any other better way to accomplish this task?
Which would be the correct way to store an array of data inside an input using jQuery or Javascript?

Thanks.

  • 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-18T19:33:51+00:00Added an answer on June 18, 2026 at 7:33 pm

    I think your apporach is good, because even if you post vars in some other kind of datastructure ex. obj or array, you have to write some code on server side to handle it.
    In this situation using explod funk is simplier to use.

    Hope this help

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

Sidebar

Related Questions

What i want to do is each time user clicks the button Add and
Each time the user clicks on cells of a table, i want add the
I'd like to change a background image of my button each time user presses
I want to iterate an Emebrjs collection - each time a user clicks next
I am new to asp.net platform. In our website, each time user clicks on
How would I add a new variable into an array each time a user
I have a table where new data gets filled each time a user clicks
I'm using NSDocumentDirectory to save an image each time user may save different different
Each time my user signs in, we pull his profile picture from Facebook. This
Hi I am creating a listbox containing 2 text boxes each time a user

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.