TAG
CSS
JavaScript
Result
Run
License
<form id="test-form" class="transmitted" method="post" action="/assist/example/http/form-receivers.php"> <label><input type="radio" name="enctype" value="application/x-www-form-urlencoded" checked />application/x-www-form-urlencoded</label> <label><input type="radio" name="enctype" value="multipart/form-data" />multipart/form-data</label> <span><input type="submit" value="Submit" /></span> </form>
#test-form { display: flex; flex-direction: column; row-gap: 10px; } .transmitted { padding: 30px 20px; position: relative; } .transmitted::before { content: "Transmit but not save"; position: absolute; background: #454545; top: 0; padding: 3px 10px; color: yellow; border-radius: 5px; }
document.addEventListener("DOMContentLoaded", () => { const $elTestForm = document.getElementById("test-form"); const $aElEnctype = document.querySelectorAll("input[name='enctype']"); const $elSubmit = document.querySelector("input[type='submit']"); $aElEnctype.forEach(elEnctype => elEnctype.addEventListener("change", setEnctype)); function setEnctype(e) { $elSubmit.formEnctype = `${e.currentTarget.value}`; } $elTestForm.addEventListener("submit", e => { $elTestForm.target = "_blank"; }); $aElEnctype[0].dispatchEvent(new Event("chabnge")); });
Console
expand_less
License
License
by DevDic
Close