Jump to content

Recommended Posts

i tried this - to disable form field if CHECKED and if UNCHECKED cancel disable. but it didnt work on my browser "chrome 33.0.1726.0" and "IE 11". please help me find out the error.....


please help me find out the error ------

<form action="#"><h3><u>Shipping Address:</u></h3>Address:<input type="text" name="shipAdd" id="shipAdd"><br /><br />City:<input type="text" name="shipCity" id="shipCity"><br /><hr align="left" width="15%" noshade color="#996666" />Billing address same as shipping address.<input type="checkbox" name="billAdd" id="billAdd"><br /><br />Address:<input type="text" name="add" id="add" class="baddr"><br /><br />City:<input type="text" name="city" id="city" class="baddr"><br /><br /><input type="submit" name="submit" id="submit" value="SUBMIT"></form><script type="text/javascript">	$(document).ready(function(e) {        $("#billAdd").click(function() {			if ($("#billAdd").attr("checked") == "checked") {				$(".baddr").val("");				$(".baddr").attr("disabled","disabled");			}			else if ($("#billAdd").attr("checked") == "undefined") {				$(".baddr").removeAttr("disabled");			}		});    });</script>
Link to post
Share on other sites

First, I wouldn't make it based on a click event of the billAdd input. Make it on the change event of the checkbox itself



then, inside that event handler, I would use is(':checked'); for testing the checkbox state



and use true / false when setting the disabled state


Link to post
Share on other sites

wow! thank u both of u for the guidance. i made it work now.


now i again stuck on retriving data for "Billing Address" from "Shipping Address" field for 'IF CHECKED' clause.


i tried this


but it didn't work.


please guide...

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...