You are viewing limited content. For full access, please sign in.

Question

Question

Set row read only with Radio button selection

asked on August 2, 2016

Hi All,

I'm trying to hide the <Add> new row button with the below code but it's not working, not sure what's missing.

$(document).ready(function () {
  $("#q6").on("change", function() {
    if($('#Field1-0').is(':checked')) {
  	$(".cf-table-add-row").show();
        }
   	 if($('#Field1-1').is(':checked')) {
    	$(".cf-table-add-row").hide();
       	}
	});
});

Also i need some help with the code on how to set a table row read only when the radio button selection is either <YES> or <NO>

Condition 1 - If Job Status="Completed" and Add more jobs = "Yes"

Show Add button and set the filled row read only after inserting a new row.

Condition 2 - If Job Status="Completed" and Add more jobs="No"

Hide Add Button and set the filled row read only.

Thanks in advance.

0 0

Replies

replied on August 3, 2016

Hi, 

I find "#q6" and "#Field1" doesn't match in your script.  I think Field 1 is a radio button, change "#q6" to "#q1“ may work

 

For another question, I wrote a script according to my assume that there is 1 row in the begining

$(document).ready(function () {
  $(".cf-table-add-row").hide();
  
  $('#q7').on("change", function() { 
    var tr= $('tr:last');
    var ra= tr.find('div[id*="Field9"]');
    if(tr.find('select option:selected').text()=='Completed')
    {
      if(ra.find('input:eq(0)').is(':checked')) {
  	      $(".cf-table-add-row").show();       
        }
        if(ra.find('input:last').is(':checked')) {
  	      $(".cf-table-add-row").hide();
          tr.find('*').attr("readonly",true);
          tr.find('*').attr("disabled",true);
        }
    }
});

  $(".cf-table-add-row").on("click", function() {
    $('tr:eq(-2)').find('*').attr("readonly",true);
    $('tr:eq(-2)').attr("disabled",true);
    $(".cf-table-add-row").hide();
  });
});

change "#q7" to id of your table, and "Field9" to id of your radio button in the table.

0 0
replied on August 9, 2016

Hi Zhenghua,

#q6 and Field 1 are the correct fields from the form.

I've used your code in the form which worked perfectly, thank you so much but if i add a date field in the same form it doesn't work. Any reasons.

Thanks again in advance.

 

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.