passing the value of a checkbok to JavaScript

I have a table and can access the data in the table with

var name =$(this).closest('tr').find('td:eq(1)').text();

$('#dialog-form input[name="empresa"]').val(Empresa);

No problem

However when I try to pass the vale of a checbox:

var name =$(this).closest('tr').find('td:eq(2)').text();

$('#dialog-form input[name="available"]').val(Empresa);

No matter if the box is checked or not it returns an empty value

When I programthe table the checkbox is either  checked or not checked according to some databse value (1 or o)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Is this your checkbox?
$('#dialog-form input[name="available"]').val(Empresa);

What is Empresa?

Post some sample HTML
robrodpAuthor Commented:

it should read

$('#dialog-form input[name="empresa"]').val(name);

you can see the script running:
This will give you a value of 1 if the checkbox is checked else 0

name = $(this).closest('tr').find('td:eq(2) input').is(":checked") ? 1 : 0

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

robrodpAuthor Commented:
Now it does get the variable but when I do:

if (Ina === '1'){
    $('#dialog-form input[name="ina"]').prop("checked", true);

To set the checkbox in with the name ina as, ina='1' it wil always tke the one value, so the ina checkbox is always on.
If lna is a number then this won't work
if (Ina === '1'){

if (Ina == '1'){
robrodpAuthor Commented:
Same result...

Once ina is set to 1 like it gets trapped
robrodpAuthor Commented:
Sorry,my mistake it does the trick.
robrodpAuthor Commented:
Pretty nifty

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.