jquery question for events

Posted by OM The Eternity on Stack Overflow See other posts from Stack Overflow or by OM The Eternity
Published on 2010-06-08T09:45:51Z Indexed on 2010/06/08 9:52 UTC
Read the original article Hit count: 341

I have to copy the text from one text box to another using checkbox through jquery I have applied jquery event in my code, it works partially correct.. code is as follows:

<html>
<head>
    <script src="js/jquery.js" ></script>
</head>
<body>
    <form>
        <input type="text" name="startdate" id="startdate" value=""/>
        <input type="text" name="enddate" id="enddate" value=""/>
        <input type="checkbox" name="checker" id="checker" />
    </form>
    <script>
    $(document).ready(function(){
            $("#startdate").change(function(o){
        if($("#checker").is(":checked")){
            $("#enddate").val($("#startdate").val());
        }

});
});
    </script>
</body>
</html>

this code works as follows, I always have checkbox checked by default hence whenever i insert the start date and then tab, the start date gets copied to enddate.

My Problem

but now if uncheck the checkbox and change the start date and then recheck the check box, the start date is not copied, Now what should be done in this situation.. please help me....

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about javascript-events