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

Question

Question

How do I read only fields that can be added?

asked on May 16, 2015

I have a form that users can add additional sections as needed.  in the section they select a department from a drop down and lookup populates the contact persons.  I want to make the contact person read only, which I can in JavaScript.  The issue is when they add a section to select another department the next section contact person field is not read only.  Here is the script I am using.
 

$(document).ready(function(){       
            $('.department_contact *').prop("readonly", true);
            $('.department_contact_copy *').prop("readonly", true);

})

 

I have also included an image of the behavior.  I just need a way to tell the form that for every department_contact and department_contact_copy make it read only. 

example.png
example.png (57.43 KB)
0 0

Answer

SELECTED ANSWER
replied on May 16, 2015

So oddly enough, I found the solution to my own question.  I replaced "ready" with "change", the JavaScript looks like this.

 

$(document).change(function(){     
    $('.department_contact *').prop("readonly", true);
    $('.department_contact_copy *').prop("readonly", true);
})

 

Works perfect!

0 0

Replies

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

Sign in to reply to this post.