You are viewing limited content. For full access, please sign in.

Question

Question

How to clear a radio button when hidden?

asked on January 28, 2021

I am using some field and lookup rules to hide a Radio Button until several fields are either empty or filled, once those conditions are meant the Radio Button will pop up. The issue is that I am using the Radio Button as a way to hide the Submit button until it's been checked, but if they meet the requirements, see the radio button, select an option and have the Submit button show up, they can then go back up and change the information above triggering the Radio Button to hide however it's not cleared or set back to default while being hidden so the Submit button is still on display allowing them to pass on possible incorrect information.

Is there a way to cause the Radio Button to revert to a default state when hidden?

0 0

Answer

SELECTED ANSWER
replied on January 28, 2021

Hi Timothy

You would have to use JS to trigger when your upper selection is made that show/hides the radio button, the remove the selections from the button.

This is not the exact code for you but a starting place as I'm unaware of what field type that first selection is.

There was also post about clearing radio button selections

$(document).ready(function(){

  $('.FieldVar input').on('change', function() {
    $('.radiofield input').prop('checked', false).change();
  });

})  

https://answers.laserfiche.com/questions/131128/unselecting-a-radio-button#144128

1 0
replied on January 28, 2021

Perfect thanks, I will try and see if I can get that to work! If you don't mind helping a bit more since I have never looked at Java until this morning, does it matter where I put that in the existing code?

$(document).ready(function(){
  // hide submit by default
  $('.Submit').hide();

  // apply event handler to radio inputs
  $('.showSubmit input').change(function(){
    // if 1 or more YES selections are found
    if(($('.showSubmit input[value="Credit Card"]:checked').length > 0)||($('.showSubmit input[value="Check"]:checked').length > 0)){
      // show submit button
      $('.Submit').show();
    }
    // otherwise  
    else{
      // hide submit button
      $('.Submit').hide();
    }
  });
});

And the variables that dictate the radio buttons hidden state are 6 single-line fields;

Invoice

PO_Number

Company_Name_POR

Invoice_Number_POR

Company_Name_INR

PO_Number_INR

with the last 4 being filled with info from SQL Lookups if it matters, the rule to show the Radio button is;

When All -

Invoice is not blank

PO_Number is not blank

Company_Name_POR is blank

Invoice_Number_POR is blank

Company_Name_INR is blank

PO_Number_INR is blank

 

 

 

0 0
replied on January 28, 2021

Hi Timothy

You can just append the code I had provided as standalone a couple lines below your current code as the code is complete and it is possible to have multiple start points in your JS

As there are multiple fields that make up the decision to clear the the radio button, my approach would likely be to create a new Single Line field with a calculation where I set up my formula to produce an outcome of Yes or No, and then I would use that field change with my JS. This way when I want to make changes in the future I can just update my field calculation and not the JS and it simplifies my JS.

Example

=IF(AND(Invoice !="",PO_Number!="",Company_Name_POR="",Invoice_Number_POR="",Company_Name_INR="",PO_Number_INR=""),"Yes","No")

 

1 0
replied on January 28, 2021

Alright, learning a lot right now! So the original one you provided works flawlessly when I put the whole code 2 lines under the existing code, I had just tossed the middle part in at the end of my other code and it didn't work.

I figured out that .VarField and .RadioField are CSS things that go in the Advanced settings for those fields so what I did was just make a hidden Single Line Field with VarField in the CSS line, changed RadioField to be showSubmit to line up with the existing CSS code on that field and set the Lookup rules to apply some SQL stuff to VarField when they find SQL stuff and it works great! Thanks for all the help!!

0 0
replied on January 28, 2021

Timothy, I think you're smarter than the average bear  :)

 

1 0
replied on January 28, 2021

I try hard lol

1 0
replied on January 28, 2021

If you don't mind, one last thing for a similar problem, do you know how I can find out what certain items are called for Java, for instance another Form I am trying to side the submit button until a signature has been added but for some reason all the codes and stuff I can find only list the reference name for the little green "sign" button when drawing and typing a name and not the larger white button that can auto sign a name if that is enabled.

 

So if there is a reference guide or something so I can learn which fields or buttons are called what that would be great!

0 0
replied on January 28, 2021

Typically in Chrome you would right click on the object in forms and in the drop down that appears choose Inspect at the bottom. This will split your screen and show you the code for the page. As you move you cursor over the form you will see more info about the fields as well.

1 0
replied on January 28, 2021

When in the CSS/Javascript screen if you click on Learn more there are some examples in the help files. Also you may want to check into W3Schools. There are tools used by programmers such as Visual Code, Netbeans, etc that can be helpful as well

1 0
replied on January 28, 2021

You are amazing! I had tried f12 and tried digging for that but I never thought to Right Click Inspect to dig right to it. Made a small tweak and it worked immediately! 

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.