User Rating: 2 / 5

Star ActiveStar ActiveStar InactiveStar InactiveStar Inactive
 

on XML form,

we can set field to readonly buy using [b]readonly="true"[/b]

 

but we can also use jQuery to set it to readonly

on views folder, open the layout file or the default.php file under the tmpl folder.

[b]joomla/administrator/com_helloworld/helloworld/tmpl/default.php[/b]

 

in order to set specific field to readonly

insert this code on your script above the table

 

<script>
jQuery(document).ready(function() {
              jQuery('#field_id').attr('readonly',true);
});
</script>

 

The code above will the field that has the same field_id which you call on your jQuery

 

if you want to set more field to readonly easier, create the same class name of every field you want to set.. and on your script, code this below

 

<script>
jQuery(document).ready(function() {
                jQuery('table').find('input.classname').attr('readonly',true);
);
</script>

 

the code above will find all field that has class="classname" and it will be set to readonly