Can anybody see why this is not working? It does not make the input field read only when the checkbox is not checked.
I have followed all the online advice so far and read much advice but even though I have followed what I could it does not work, however it throws no errors.
Would be great-full if anybody can see why.
<div class='div1'>
<input type="checkbox" class='Xcheckbox' id="byname" name="searchforname" title='Search For All Listings With Sellers Name' value="sellersname" onclick="chbxX(this); <?php $extrasearch==='sellersname'; ?>" <?php if ($extrasearch==='sellersname' ): ?> checked="checked"
<?php endif; ?> >
<label for="byname" class='nameheader' title='Search Date Range'>
<b>Seller's Name</b>
</label>
<input type="text" id='sellersname' name="SellersName" placeholder="Sellers Name" class="sellersname" title='Type The Sellers Name' value="<?php echo $sellersname ?>">
</div>
<script>
$(function() {
if ($("#byname").prop('checked') == false) {
document.getElementById("sellersname").setAttribute("readonly", true);
} else {
document.getElementById("sellersname").removeAttribute("readonly");
}
});
</script>