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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:30:25+00:00 2026-05-22T02:30:25+00:00

I have the following jQuery function embedded in an MVC Razor page: <script type=text/javascript>

  • 0

I have the following jQuery function embedded in an MVC Razor page:

<script type="text/javascript">
    $(document).ready(function () {
        $("input[name=MultiListsetting]").change(function () {
            var valueString = "";
            $("input[name=MultiListsetting]:checked").each(
            function () {
                valueString += this.id + ","
            }
            );
            var MultiValueListResult = valueString.slice(0, -1);
            alert(MultiValueListResult);
        });
    });
</script>

This outputs a string based on the id attribute of a series of checkboxes. When a checkbox value changes, the string gets rebuilt. So with 3 checkboxes, all checked, the function will output: “checkboxID1,checkboxID2,checkboxID3” until changed. This is the way our DB server stores values for this set of checkboxes. What I need to accomplish now is pass the string that this function outputs to a hidden HTML element on the same Razor page.

@Html.Hidden("SetViewModel[" + i + "].Value", [string output here])

Will jQuery allow this move? Can I somehow take “MultiValueListResult” and plop it into the hidden control? I’m still researching.

  • 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-22T02:30:25+00:00Added an answer on May 22, 2026 at 2:30 am

    You’re mixing execution time in your template methinks; your HTML hidden field will be on the page long before the jQuery is executed. What you need to do is simply make your hidden field:

    @Html.HiddenFor(x => x.MyPropertyName);
    

    And then in your callback, simply update it’s value:

    $('#myElement').change(function()
    {
        $('#MyPropertName').val(MultiValueListResult); 
    });
    

    When the form gets posted back, the value of your selected set will be contained within the hidden value.

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

Sidebar

Related Questions

I have the following jquery code that I've embedded inside of a View: $(document).ready(
I have the following jquery that I wrote: $(document).ready(function(){ $('div.contentTxtBox#home').addClass('current').show(); $('a.menu').click(function() { $('div.contentTxtBox.current').hide(slide, {
I have the following jQuery function (simplified): function doSomething(el, str) { el.find('.class').text(str)); } Don't
I have the following JavaScript (with jQuery) $(function() { $(.btnDesc).click(function() { $(#desc).slideToggle(slow); $(this).toggleClass(active); });
Let's say I have the following jQuery AJAX call: $.ajax({ type: POST, url: MyUrl,
I have the following JQuery function being attached to the blur event of n
I have the following jquery code: jQuery(function(){ jQuery(select#rooms).change(function(){ var options = ''; jQuery.getJSON(/admin/selection.php,{id: jQuery(this).val(),
I have the following jQuery function: function GetGrandparentDiv(item) { return item.parents('div:eq(1)'); } Which is
I have the following jquery function for filtering the contents of a listbox on
I have the following jquery function for some links $(.clickable).click(function(event){ // load dialog content...

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.