Hi all,
I have a form in which a checkbox is to be used to copy entries from some form textboxes to other textboxes. When the checkbox is to be clicked to the checked state the copy occurs. When the checkbox is clicked to uncheck it, the textboxes are to be cleared.
What happens is -- the first click works -- the box is checked and the copy action occurs. But further clicking does not work. The checkbox stays checked.
I'd guess that the first IF always runs. Here is the routine:
function namecopy() {
if (document.getElementById("chkCopyName").checked=true) {
document.getElementById("cc_firstname").value=document.getElementById("firstname").value;
document.getElementById("cc_lastname").value=document.getElementById("lastname").value;
document.getElementById("cc_address1").value=document.getElementById("address1").value;
document.getElementById("cc_address2").value=document.getElementById("address2").value;
document.getElementById("cc_city").value=document.getElementById("city").value;
document.getElementById("cc_state").value=document.getElementById("state").value;
document.getElementById("cc_zip").value=document.getElementById("zip").value;
}
if (document.getElementById("chkCopyName").checked=false {
document.getElementById("cc_firstname").value="";
document.getElementById("cc_lastname").value="";
document.getElementById("cc_address1").value="";
document.getElementById("cc_address2").value="";
document.getElementById("cc_city").value="";
document.getElementById("cc_state").value="";
document.getElementById("cc_zip").value="";
}
}
The second IF never runs.
Here is how the action is initiated:
<input type="checkbox" name="chkCopyName" ID="chkCopyName" onClick="namecopy()" />
Any ideas??
Thanks,
KB
I have a form in which a checkbox is to be used to copy entries from some form textboxes to other textboxes. When the checkbox is to be clicked to the checked state the copy occurs. When the checkbox is clicked to uncheck it, the textboxes are to be cleared.
What happens is -- the first click works -- the box is checked and the copy action occurs. But further clicking does not work. The checkbox stays checked.
I'd guess that the first IF always runs. Here is the routine:
function namecopy() {
if (document.getElementById("chkCopyName").checked=true) {
document.getElementById("cc_firstname").value=document.getElementById("firstname").value;
document.getElementById("cc_lastname").value=document.getElementById("lastname").value;
document.getElementById("cc_address1").value=document.getElementById("address1").value;
document.getElementById("cc_address2").value=document.getElementById("address2").value;
document.getElementById("cc_city").value=document.getElementById("city").value;
document.getElementById("cc_state").value=document.getElementById("state").value;
document.getElementById("cc_zip").value=document.getElementById("zip").value;
}
if (document.getElementById("chkCopyName").checked=false {
document.getElementById("cc_firstname").value="";
document.getElementById("cc_lastname").value="";
document.getElementById("cc_address1").value="";
document.getElementById("cc_address2").value="";
document.getElementById("cc_city").value="";
document.getElementById("cc_state").value="";
document.getElementById("cc_zip").value="";
}
}
The second IF never runs.
Here is how the action is initiated:
<input type="checkbox" name="chkCopyName" ID="chkCopyName" onClick="namecopy()" />
Any ideas??
Thanks,
KB