i have dynamic created form textbox , radiobutton , want them work together.
if write in textbox want radiobutton unchecked , if radiobutton checked want textbox empty. i've tried lot of different things , of them wont work because of dynamic created form.
here javascript code doesn't work, maybe it'll realize want do.
function radiobox() { if (document.getelementbyid("abdominalcircumferencetextbox").text == "") { document.getelementbyid("abdominalcircumferenceradio").checked = true; } } edit: ive solved doing this!
$(document).on("change", "#abdominalcircumferencetext", function () { $("#abdominalcircumferenceradio").prop('checked', false); }); $(document).on("change", "#abdominalcircumferenceradio", function () { $("#abdominalcircumferencetext").val(""); });
as you've mentioned jquery in tags, simple way of doing using jquery is:
<input type="text" id="mytextbox" /> <input type="checkbox" id="mycheckbox" checked /> with associated javascript:
$(document).ready(function() { $("#mytextbox").keyup(function() { $("#mycheckbox").prop("checked", $(this).val() == ""); }); $("#mycheckbox").change(function() { $("#mytextbox").val(""); }); }); demonstration here: http://jsfiddle.net/rs5ec/1/
Comments
Post a Comment