Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..

cancel
Showing results for 
Search instead for 
Did you mean: 

Populate a Read Only field with JavaScript?

JayFogelson2
Contributor III

I'm wondering if there is a way/different syntax to use to populate a text field, that is being made read only with a DDE?

The below works, when the field is not being made read only. 

 

The odd thing is the when I check the value with an alert, such as:

alert($('input[id*="f' + textUserField + 'c"]').val());

It works when it's both editable and read only.

<script type="text/javascript">
var userPermField = 20936;
var textUserField= 20937;


Sys.Application.add_load(function() {
var newUserName = $('div[id*="f' + userPermField + 'c"]').text().trim().replace('Pick','');
$('input[id*="f' + textUserField + 'c"]').val(newUserName);
});
</script>
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
21 REPLIES 21

Thank you David.

Date field

$('input[name$="' + fldIds.Date + 'cdp"]').prop("value", DateValue);

Dropdown Values list:

    function SetValueList(fldId, value) {
        if (value != '' && value != undefined) {
            value = JSON.parse(Value);
            value = Value.value;

            var valueArray = new Array(1);
            valueArray[0] = value;
            ArcherTech.UI.GenericContent.GetInstance().setFieldValue(fldId, valueArray, '');
        }

    }

This value for the dropdown was displayed correctly

"{"enabled":true,"value":"12345:0","text":"Auditor","selected":true,"active":true}"

While this value for another dropdown (Selected year field) didn't display on the layout until after first save

"{"enabled":true,"text":"2024","value":"45678:0","selected":true,"html":null}"

 

 

@DavidPetty 

I'm still unable to get the above read-only fields to display the values before clicking the Save button. After I click Save, fields are populated on these read-only fields without any issues.