你好,我是一名学生,最近我正在学习 JavaScript、CSS 和 HTML,在做练习时我遇到了问题。
在练习中,我使用 Bootstrap。
function Form(stringa){
document.getElementById("form1").style.display="none";
document.getElementById("form2").style.display = "none";
document.getElementById(stringa).style.display = "block";
}
<!doctype html>
<html>
<head>
<title>Form di registrazione</title>
</head>
<body>
<div class="container">
<h1>Form di Registrazione</h1>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" value=1 onclick="Form('form1');" >
<label class="form-check-label" for="inlineRadio1">Privato</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" onclick="Form('form2'); " value=2>
<label class="form-check-label" for="inlineRadio2">Azienda</label>
</div>
<form id="form1" class="row g-3" value=1>
<div class="col-md-6">
<label for="inputEmail4" class="form-label">Email</label>
<input type="email" class="form-control" id="inputEmail4">
</div>
<div class="col-md-6">
<label for="inputPassword4" class="form-label">Password</label>
<input type="password" class="form-control" id="inputPassword4">
</div>
</form>
<form id="form2" type="hidden"class="row g-3"style="display:none;" value=2>
<div class="col-md-6">
<label for="inputEmail4" class="form-label">Eeeeee</label>
<input type="email" class="form-control" id="inputEmail4">
</div>
</form>
</div>
</body>
</html>
为什么当我单击单选按钮时它会更改表单布局?
拉风的咖菲猫
相关分类