chrisjk
May 12th, 2002, 12:32 PM
I have a checkbox in a form. When the user ticks the box, I want a string to be entered into text box in the same form. If they untick the box, I want the value to be cleared in the text box
<script language="javascript">
<!--
function inserthttp() {
if (document.add_product.Multipage.value = 1) {
document.add_product.MultipageURL.value = "some value"
} else {
document.add_product.MultipageURL.value = ""
}
}
//-->
</script>
.........
<input type="checkbox" name="Multipage" value="1" onclick="javascript:inserthttp();">
This will insert the "some value" when you click on the checkbox, but it won't clear the value when you click on it again.
Any ideas?
<script language="javascript">
<!--
function inserthttp() {
if (document.add_product.Multipage.value = 1) {
document.add_product.MultipageURL.value = "some value"
} else {
document.add_product.MultipageURL.value = ""
}
}
//-->
</script>
.........
<input type="checkbox" name="Multipage" value="1" onclick="javascript:inserthttp();">
This will insert the "some value" when you click on the checkbox, but it won't clear the value when you click on it again.
Any ideas?