Forums

How to reference a field with model id in Javascript

amsharma 05 Mar, 2014
Hello,

A very basic question whose answer I couldn't find. How do I refer to a form field after I have added "Model Id" to it. I was earlier using a form without using a model id and wrote the following code:
document.cf_myform.ip_bit_approved.readOnly = true;
in Load JS to make a field Read Only.

This was working fine. I had to add Model ID because of the corresponding CC connection usage. Now the field name in form is: ab[ip_bit_approved], which was earlier ip_bit_approved. I tried many options including
document.cf_myform.ab.ip_bit_approved.readOnly = true;
but it didn't work.

The script has stopped working and I can't get it to work. How do I refer to this field in Javascript.

Thanks
Amal
GreyHead 05 Mar, 2014
Hi Amal,

If the id in the Form HTML is ab[ip_bit_approved] then I'd suggest that you try document.ab[ip_bit_approved] or, using the MooTools syntax $('ab[ip_bit_approved]')

Bob
Max_admin 12 Mar, 2014
Maybe you can simply add an "id" attribute to the field and use
$("field_id")
?

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.