0

whether or not my variable "showforfamilymember" has a value of true or false it always the show checkbox as checked

        <label for="showforfamilymemberchk">Show This Group While Adding Family Member</label>
        <input type="checkbox" name="showforfamilymemberchk" id="showforfamilymemberchk" />

jQuery

var txtshowforfamilymember = $("#showforfamilymemberchk");
txtshowforfamilymember.attr("checked", showforfamilymember);

2 Answers 2

1

How are you setting showforfamilymember ?

If you do it like this it should work

var showforfamilymember = false;

if you have the value stored let's say in some string "myValue"

var showforfamilymember = (myValue.toLowerCase() === 'true');

Hope it works

Sign up to request clarification or add additional context in comments.

Comments

1

Try using .prop() instead of .attr()

txtshowforfamilymember.prop("checked", showforfamilymember);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.