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

http://stackoverflow.com/questions/3642993/jquery-on-checked-toggle-box

 

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

http://stackoverflow.com/questions/8391084/how-to-check-if-check-box-is-checked-in-this-example-javascript-jquery

 

and use true / false when setting the disabled state

http://stackoverflow.com/questions/1414365/how-to-disable-enable-an-input-with-jquery

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

				$("#add").val($("#shipAdd"));

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.

Guest
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.

Loading...
×
×
  • Create New...