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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:41:38+00:00 2026-05-29T08:41:38+00:00

I have the following code: $(input[id^=’Order_’], input[id^=’Default_’]) .change(function (e) { var type = $(this).attr(‘id’).split(‘_’)[0];

  • 0

I have the following code:

$("input[id^='Order_'], input[id^='Default_']")
   .change(function (e) {
      var type = $(this).attr('id').split('_')[0];
      updateField('Menu', $(this), type);
});

The input with an id of 'Order_' has a type="text"
The input with an id of 'Default_' has a type="checkbox"

In my updateField I have a problem:

function updateField(entity, obj, type) {
    var val = obj.val();
    var idArr = obj.attr("id");
    var idTmp = idArr.split("_");
    var id = idTmp[1];
    var pkrk = $("span[id='refKey_" + id + "']").html();

The problem is that the code works good for the text but not for the checkbox. If the checkbox is checked or not then it still returns true. Is there a way that I can get the value of if the checkbox is checked or not and either put the string “true” or “false” into the variable val while still having the correct value put into val if the date is coming from the Order_ ?

So if the value of Order_ field is 25 then val = "25"
So if the value of Default_ checkbox is true the val = "true"
So if the value of Default_ checkbox is false the val = "false"
  • 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-29T08:41:39+00:00Added an answer on May 29, 2026 at 8:41 am

    The problem is that the checkbox doesnt have any “value”. Instead of using the val() function in jQuery search for the attribute “checked”.
    This can be done as such:

    var checked = !!$("checkbox selector").attr("checked");
    

    Or using the jQuery selectors

    var checked = $("checkbox selector").is(":checked");
    

    So the attr() function will return undefined if the checkbox tag doesnt contain the attribute “checked” and that is the same as the unchecked state of the checkbox.

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

Sidebar

Related Questions

I have following code snippet: var reg = /^[0-9]$/; $('input[type=text]').keypress(function(){ console.log(reg.test(parseInt($(this).val()))); }); When I
I have the following snippet of code: $('input#teamName').live('blur', function() { var value = $(this).val();
i have the following code : <input type=text value=<?php echo $_GET['msg']; ?>> This input
I have the following code: $('#DoButton').click(function (event) { event.preventDefault(); $(input:checked).each(function () { var id
I have the following code jQuery(.opsection input).live('change', function(){ What i want to also do
I have the following code: $(input[id$=UserField_hiddenSpanData],input[title=Title]).each(function(){ var rb = $('#ctl00_m_g_c6ae303a_6013_4adb_8057_63a214bcfd24_ctl00_ctl04_ctl07_ctl00_ctl00_ctl04_ctl00_ctl00_SelectResult option').length; var val =
I have following code in a html form <select name=category class=input onchange=ShowTB(this,'suggest');> <option value=0
Hi I have the following code <input type=submit name=btnCheckOut value=Buy >> id=btnCheckOut /> I
I have following code (html,js,jquery) snippet ( http://jsfiddle.net/MUScJ/2/ ): <script type=text/javascript> function someFunc(){ html
I have the following code, which works fine: <input type=button name=btnHello value=Hello onclick=Test();/> and

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.