Forum Moderators: open

Message Too Old, No Replies

jquery conditonal question

         

neophyte

9:54 am on Jun 12, 2011 (gmt 0)

10+ Year Member



Hello All -

This seems pretty straight forward, but I can't make it work.

I'm getting an id from a td element that's being fed into var currentId.

Now, if input#dateIn is NOT empty, AND input#dateOt IS empty, then the value of currentId needs to go into input#dateOt.

What's happening is that my little script snipped below is feeding the currentId into both #dateIn AND #dateOt inputs.

if (($('input#dateIn').val() != '') && ($('input#dateOt').val() == '')){
$('input#dateOt').val(currentId);
}

Apparently I'm going wrong with the "&&" operator or some other syntax error I can't see.

Can someone please straighten me out?

Thanks to all in advance.

Neophyte

daveVk

12:21 pm on Jun 12, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only place I see any 'feeding' going on is here ?

$('input#dateOt').val(currentId);

So #dateIn should not change regardless of the if condition, make sure inputs have correct ids, and for any other references to #dateIn.

neophyte

4:06 am on Jun 13, 2011 (gmt 0)

10+ Year Member



Hello Dave -

Indeed, there was another if statement above the one in question which did re-feed #dateIn.

Thanks very much for your assistance. Will likely be back with other jquery questions regarding this project.

Thanks again.

Neophyte