JSFiddle - React, Tailwind, and code Playground

HTML

<input type="radio" name="group" value="book_folder" onchange="makeRadioButtons()">Create New Book</input>

<input type="radio" name="group" value="book_chapter" onchange="makeRadioButtons()">Create New Chapter</input>

JavaScript

function makeRadioButtons()
{    
        var test = document.getElementsByName("group");
    
        for(var elem in test)
        {
            if(test[elem].checked)
            {
                alert(test[elem].value);  // got the element which is checked      
                if(test[elem].value=="book_folder")
                    alert("Need to create book");
                else if(test[elem].value=="book_chapter")
                    alert("Need to create book chapter");      
            }
        }
}