Jump to content

Hide Button and Label Based On Checked Box

Recommended Posts

I have set this up to do the following:

- hide the  "Choose File" button when a file has already been uploaded

- hide the remove checkbox button when status is "Accepted" 

<input type="checkbox" id="EditRecordClient_information_sheetRemove" name="EditRecordClient_information_sheetRemove" value="true" style="visibility: hidden;">

What I can't get it to do is hide the label "Remove" next to the checkbox.

<label for="EditRecordClient_information_sheetRemove">Remove</label>


var fileCIS='[@field:Client_information_sheet/]';
var statusCIS='[@field:Client_information_sheet_status]';

if (fileCIS.length>0)
document.getElementById("EditRecordClient_information_sheet").style.visibility = 'hidden';

if (statusCIS.length='Accepted')
document.getElementById("EditRecordClient_information_sheetRemove").style.visibility = 'hidden';

if (statusCIS.length!=='Accepted')
document.getElementById("EditRecordClient_information_sheetRemove").style.visibility = 'visible';


Link to comment
Share on other sites

Try targeting just the "label" tag .. then zone into which specific label tag to affect by changing the bracketed number [0], [1] etc. next to it. See my code below.

<script type="text/javascript">
    document.addEventListener('DataPageReady', function (event) {
    function myFunction() {
      var labelTarget = document.getElementsByTagName("form")[0];
      labelTarget.getElementsByTagName("label")[0].innerHTML = "";

    • The first part of the code finds the 1st[0] "form" tag
    • 2nd part of the code targets ALL the "label" tags as an array, but the unique label you want is found here > [0] .. this number needs to change until you find your specific label . once found, the script makes the label's HTML text become BLANK with the code call innerHTML = "" -->


Link to comment
Share on other sites

  • 2 years later...

I'm able to hide "Choose File" button  by inserting the following code into the footer.  However, it seems to show again once I click the "Update" button.  Any ideas?

var UploadA='[@field:Credential_Upload_A]';

if (UploadA.length>0)
document.getElementById("EditRecordCredential_Upload_A").style.visibility = 'hidden';
document.getElementById("EditRecordCredential_Upload_ARemove").style.visibility = 'hidden';



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.

Reply to this topic...

×   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.


  • Create New...