Jump to content
  • 0

Change Field Label Conditionally?


brbbrid

Question

I have a cascading dropdown where the lookup values change based on the dropdown above it, so the values will change based on the first selection.  I need to change the field label of the 2nd dropdown based on the selection of the first dropdown.  

 

So if it the dropdown value for the 1st dropdown is "A", then the field label for the 2nd dropdown would change to "Select "A" submission:" and if "B" is selected for the dropdown value for the 1st dropdown, then the field label for the 2nd dropdown would change to "Select "B" submission:" as an example.  I actually have 2 words that would be static for each selection, so I don't necessarily need to grab the text from the dropdown, I just need to be able to switch the label for the 2nd dropdown based on the 1st dropdown selection. 

 

Is there a way to do this somehow with a rule conditionally or a JavaScript that would work? 

 

Thank you in advance to anyone able to help! 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hello brbbrid,

 

If I understand correctly, you work with the Search page of the Report DataPage.

You can try the following code:

<SCRIPT LANGUAGE="JavaScript">

var dropdownElement = document.getElementsByName("Value1_1")[0];
var value_for_label = dropdownElement.options[dropdownElement.selectedIndex].value;
document.getElementsByName("Value2_1")[0].parentNode.previousSibling.firstChild.innerHTML= "Select " + value_for_label + " submission";

function change_label()
{
var dropdownElement = document.getElementsByName("Value1_1")[0];
var value_for_label = dropdownElement.options[dropdownElement.selectedIndex].value;
document.getElementsByName("Value2_1")[0].parentNode.previousSibling.firstChild.innerHTML= "Select " + value_for_label + " submission";
}

document.getElementsByName("Value1_1")[0].onchange=change_label;
</SCRIPT>

Please enter your values instead of "Value1_1" and "Value2_1".

The first number is the form element order, which starts at 1 and increments based on the order of the element in the form.

 

I hope, it helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...