Page 1 of 1

Set Placeholder programmatically

Posted: Thu Aug 02, 2018 4:25 am
by aura9k1
Good day,

Is there a way to change the Placeholder value of a field using Javascript? Using setValue or setText does of course not achieve the required result.

Re: Set Placeholder programmatically

Posted: Thu Aug 02, 2018 11:51 pm
by amosbatto
You can use this JavaScript code:
Code: Select all
$("#form\\[my_field\\]").prop("placeholder", "My new placeholder");
Where the ID of the field is "my_field".

Re: Set Placeholder programmatically

Posted: Mon May 10, 2021 4:09 am
by ewallace
Given a main form named "Employee Info" which includes a subform named, "subform Checklist", which has a dropdown control named "Department Head", how would I set the PLACEHOLDER for "Department Head" via JavaScript?

Explanation of partial trigger code further below:
"departmentHead" is a dropdown on "subform Checklist" with a PLACEHOLDER of "Please select from list"
If they select "yes" for "bannerAccount", select a value from the dropdown for "departmentHead", then set "bannerAccount" back to "no", I clear the value for "departmentHead".

However, this eliminates the "Please select from list" PLACEHOLDER if they later change "bannerAccount" back to "yes",
thus displaying the top value for "departmentHead" by default.

How do I set "departmentHead" back to the PLACEHOLDER value after I clear it?

function showOrHide_bannerAccountDetails() {
if ($("#bannerAccount").getValue() === "yes") {
$("#departmentHead").show();
$("#departmentHead").enableValidation();
$("#accessPrivsLike").show();
$("#additionalBannerAccess").show();
...
} else {
$("#departmentHead").hide();
$("#departmentHead").disableValidation();
$("#departmentHead").setValue("");
...

Re: Set Placeholder programmatically

Posted: Mon May 10, 2021 9:10 pm
by kirkwg
Hi there,

I want to help but still don't get a full picture for your question? Mind to draw a picture or give example to show what is before it looks like and what is after it looks like?? Thanks.

Re: Set Placeholder programmatically

Posted: Tue May 11, 2021 9:34 am
by ewallace
Please see the details in the attached "Javascript show-hide error details.txt" file and view a Zoom recording of the issue here:

https://ellucian.zoom.us/rec/share/5--GmBDiTcc0V9zYyb0SRRymWMn1U50uE07LoePzNFLLlxHml9LFDCtaIji3xFSu.8r1iZEwm_XFf75Ng
(Access Password: 6dD^1%7B)
(1.92 KiB) Downloaded 283 times

Re: Set Placeholder programmatically

Posted: Tue May 11, 2021 11:12 pm
by kirkwg
Hi there,

Thanks for your explanation, now I understand your issue. What you had encountered the behaviors were normal, if based on processmaker doc below for 1/ and 2/:

1/Only the dropdown control always selects a value when it is first rendered. In order to define an empty or null value, create an option without value and add any description such as “--Select an option--”.

2/ Placeholder - Once an option is selected the placeholder will disappear.

//my suggestion below:
Placeholder only show one time at initial, once you have selected an option or you reset it to empty "" by JS, the same, won't show the placeholder again.

Solution: e.g. add " --Please select a choice--" as a null choice and check later
-- --Please select a choice--
NEW NEW
PREV Take over previous number

Cheers...