JavaScript UI Libraries & Blazor Components Suite – Smart UI Forums General Discussions uncheck a radioButton after the values are submitted?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #102304
    tlockhart6
    Member
    Up
    0
    Down

    I have a quiz webcomponent (written in javascript) that uses radio-buttons to retrieve user input.  I would like to clear the radio-button after the question is submitted, in order to use the same form.  However, I am not able to uncheck the button once it has been checked.  Can anyone advise  how I can uncheck the radio-button, after a click event?

    #102305
    YavorDashev
    Member
    Up
    0
    Down

    Hi Tony,
    When you have radio buttons grouped always one of the radio buttons must be checked as this is the proper behavior of RadioButton component.
    However if you need to set the checked button to be the same before the form is submitted I have prepared a quick code snippet that showcases how to set the checked property of the first radio button component:

     //In your click/submit handler funciton:
    const radiobuttons = document.querySelectorAll('smart-radio-button ');
            radiobuttons[0].checked= true;
    

    Let me know what you think!
    Please, do not hesitate to contact us if you have any additional questions.
    Best regards,
    Yavor Dashev
    Smart UI Team
    https://www.htmlelements.com/

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.