set the value for a checkbox using .prop

So, I have in my script the following code to assign the value of several text boxes that is working ok.

However, when I attempt to assign the value of a checkbox, nothing seems to be set for the checkbox. I have tried using .prop and .attr, so I am thinking my entire approach is wrong.

Some help would be greatly appreciated.

Here is my unchanged code. I am trying to assign the value of the "#id_language_detail_multiple_languages":

    function setLanguageDetailsFormValues() {

    $('#id_language_detail_display_type').val('{{ language_details.language_detail_display_type }}');

    $('#id_language_detail_multiple_languages').val('{{ language_details.language_detail_multiple_languages }}');



If you want to assign the "value" of your text boxe, you will add to do something like this:

$('#YourId').attr('value', 'setYourValueHere')

If you want to have the value of your text box, just do:

var myValue = $('#YourId').attr('value')

That is the same thing for '.prop' !

If it wasn't what you wanted, be a little more specific or give us a :-)

By the way, you can also do:

if you go 1 checkbox:


Or just:

document.getElementById('yourCheckbox').value = 'YourValue';

If the value isn't set, it will return undefined, so be aware and check if it is !

Hi You can do it like following.Properties for checkboxes are different from textboxes.


if you want to read the checkbox value use like following



Need Your Help

Visual Studio adding OvalShape and RectangleShape tool references to a project

c# visual-studio-2008

Trying to add a 'box' to a form at design time, I looked up the msdn and it clearly states that I should be able to do this using the OvalShape and RectangleShape control tools in my Visual Studio ...

How do you allow only inputs from a list? (python vending machine)

python python-3.x

I need to code a vending machine, that only accepts certain coins