Skip to main content
Inspiring
July 12, 2012
Question

onchange event?

  • July 12, 2012
  • 1 reply
  • 1121 views

I have two text boxes with diffrent datepicker hooked them up.

Txt1 shows the default to the current date.

Txt2 allows  user to pick the date from the picker calendar.

I want the date in txt1 change to the same date from txt2 when user picks the date from the picker.

How can i accomplish that? Thank you very much.

Thanks

This topic has been closed for replies.

1 reply

Inspiring
July 12, 2012

Using bind might work.  Alternatively, write a javascript function that sets the value of txt1 to the value of txt2 and call it on txt2's onchange attribute.

kt03Author
Inspiring
July 12, 2012

tried this but didn't work

<script>

function checkValue (el){

     if (el.value != ""){

          document.getElementById("txt1").value = el.value;

     }

}

</script>

<cfform>

<cfinput type="datefield"  name="txt1" id="txt1" value="" size="12" required="no">                       

<cfinput type="datefield" onblur="checkValue(this);"  name="txt2" id="txt2" value="" size="12" required="no">

</cfform>

Inspiring
July 12, 2012

Troubleshooting js is one of my least favourite things to do.  Start by making sure the function is actually executing.

function checkValue (el){

alert("working");

     if (el.value != ""){

          document.getElementById("txt1").value = el.value;

     }

Then add eI.value to the mix to ensure it's what you expect.