skip to Main Content

Unable to get the list of checked checkboxes onsubmit – Javascript

I have a NextJS app where I have this form: <form id='roles-form' action='#' onSubmit={handleSubmit}> <ul className='h-56 overflow-y-auto p-3'> {roles.role.map((role) => { return ( <li key={role.roleId}> <div className='flex rounded p-3 hover:bg-gray-100'> <label className='relative inline-flex w-full cursor-pointer items-center'> <input type='checkbox' name='roles' value={role.roleId}…

VIEW QUESTION

Why can't I initialize a global variable from another global variable containing an HTML element

index.html file <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="1script.js" defer></script> <title>Document</title> </head> <body> <form id="form1" name="userInputForm"> <label for="moq">MOQ:</label><br> <input type="number" id="moq" name="moq" onfocusout=""><br> <br> <div id="calculate"><input type="button" name="button" style="width: 8rem; height: 2rem;"…

VIEW QUESTION

Button's onClick function does not call window.location when the form input fields have values – Html

function register() { var email = document.getElementById("emailData2").value; var password = document.getElementById("passwordData2").value; localStorage.setItem("localemail", email); localStorage.setItem("localpassword", password); window.location.replace("https://accountdemo.netlify.app"); } document.getElementById("registerButton").addEventListener("click", register); The window.location.replace() method only works when I press the button alone. If I fill out the email & password fields and…

VIEW QUESTION
Back To Top
Search