mardi 7 août 2018

Checkbox enable readonly Input Not working

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, Thank you...

<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; ?> ></input>

<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 ?>"  ></input>

</div>


<script>
$(function(){

if($("#byname").prop('checked') == false){
    document.getElementById("sellersname").setAttribute("readonly", true);
  } else {
    document.getElementById("sellersname").removeAttribute("readonly");
  }


});
</script>




Aucun commentaire:

Enregistrer un commentaire