Link to home
Start Free TrialLog in
Avatar of robrodp
robrodpFlag for Mexico

asked on

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)
Avatar of Gary
Gary
Flag of Ireland image

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

What is Empresa?

Post some sample HTML
Avatar of robrodp

ASKER

Ok,,

it should read

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

you can see the script running:

http://parquevehicular.com/panelx/expertxx.asp#
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of robrodp

ASKER

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'){

Use
if (Ina == '1'){
Avatar of robrodp

ASKER

Same result...

Once ina is set to 1 like it gets trapped
Avatar of robrodp

ASKER

Sorry,my mistake it does the trick.
Avatar of robrodp

ASKER

Pretty nifty

Thx