我试图在单选按钮更改时隐藏两行。我有一个问题(您的邮政地址是否与您的居住地址相同),使用标有 YES/NO 的单选按钮询问用户 如果用户选中 YES,则两行保持未选中状态,如果选中 NO,则 div 现在将全部显示给他们作业正常但是当我检查否但它显示它像这样
但它应该像这样向我展示 这是我的代码`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="keywords" content="HTML5 Template" />
<meta name="description" content="Webmin - Bootstrap 4 & Angular 5 Admin Dashboard Template" />
<meta name="author" content="potenzaglobalsolutions.com" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<title>Recruitment</title>
<!-- online Bootsrtap -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3 Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<style>
/*a:link {
text-decoration: underline;
}
a:hover {
text-decoration: none;
}*/
input[type='radio'] {
transform: scale(2);
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="content-wrapper" style="margin-left:0px">
<div class="page-title">
<div class="row">
<div class="col" style="text-align:center;font-size: 25px;font-family: sans-serif;">
<h4 class="mb-0">Application Form</h4>
</div>
</div>
</div>
<br/>
<br/>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-3">
<label class="control-label" for="emailAddr"><b>Current Email Address</b></label>
</div>
<div class="col-3">
<input required type="email" style="width:300px" class="form-control" id="emailAddr">
</div>
<div class="col-3">
<label class="control-label" for="phonenum"><b>Mobile number</b></label>
</div>
<div class="col-3">
<input required type="number" style="width:300px" class="form-control" id="phonenum">
</div>
</div>
<br><br>
<div class="row">
<div class="col-3">
<label class="control-label" for="surname"><b>Surname</b></label>
</div>
<div class="col-3">
<input required type="text" style="width:300px" autocomplete="off" class="form-control" id="surname" name="surname" />
</div>
<div class="col-3">
<label class="control-label" for="givenname"><b>Given name</b></label>
</div>
<div class="col-3">
<input required type="text" style="width:300px" autocomplete="off" class="form-control" id="givenname" name="givenname" />
</div>
</div>
<br><br>
<div class="row">
<div class="col-3">
<label class="control-label" for="preferredname"><b>Preferred name</b></label>
</div>
<div class="col-3">
<input required type="text" style="width:300px" autocomplete="off" class="form-control" id="preferredname" name="preferredname">
</div>
<div class="col-3">
<label class="control-label" for="streetaddress"><b>Street address</b></label>
</div>
<div class="col-3">
<input required type="text" style="width:300px" autocomplete="off" class="form-control" id="streetaddress" name="streetaddress">
</div>
</div>
<br><br>
<div class="row">
<div class="col-3">
<label class="control-label" for="status"><b>State</b></label>
</div>
<div class="col-3">
<select class="form-control" style="width:300px" id="state" name="state">
<option value="0">Select State</option>
<option value="1">QLD</option>
<option value="2">NSW</option>
<option value="3">VIC</option>
<option value="4">TAS</option>
<option value="5">ACT</option>
<option value="6">WA</option>
<option value="7">SA</option>
<option value="8">NT</option>
</select>
</div>
<div class="col-3">
<label class="control-label" for="postcode"><b>Postcode</b></label>
</div>
<div class="col-3">
<input required type="number" style="width:300px" autocomplete="off" class="form-control" id="postcode" name="postcode">
</div>
</div>
<br><br>
<div class="row">
<div class="col-3">
<label class="control-label" for="postalcheck"><b>Is your postal address the same as your residential address</b></label>
</div>
<div class="col-3">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="1" onchange="getValue(this)">
<label class="form-check-label" for="inlineRadio1"> <b>Yes</b></label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="2" onchange="getValue(this)">
<label class="form-check-label" for="inlineRadio2"> <b>No</b></label>
</div>
</div>
<div class="col-3">
<label class="control-label" for="resume"><b>Upload a recent copy of your resume</b></label>
</div>
<div class="col-3">
<input type="file" id="resume" name="resume">
</div>
</div>
<br><br>
<div class="row" id="postalone">
<div class="col-3">
<label class="control-label" for="postalstate"><b>Postal: State</b></label>
</div>
<div class="col-3">
<select class="form-control" style="width:300px" id="state" name="state">
<option value="0">Select Postal State</option>
<option value="1">QLD</option>
<option value="2">NSW</option>
<option value="3">VIC</option>
<option value="4">TAS</option>
<option value="5">ACT</option>
<option value="6">WA</option>
<option value="7">SA</option>
<option value="8">NT</option>
</select>
</div>
<div class="col-3">
<label class="control-label" for="postpostcode"><b>Postal: Postcode</b></label>
</div>
<div class="col-3">
<input required type="text" style="width:300px" class="form-control" id="postpostcode" name="postpostcode">
</div>
</div>
<br><br>
<div class="row" id="postaltwo">
<div class="col-3">
<label class="control-label" for="poststraddr"><b>Postal: Street address</b></label>
</div>
<div class="col-3">
<input required type="text" style="width:300px" class="form-control" id="poststraddr" name="poststraddr">
</div>
</div>
<br><br>
<p class="text-muted pt-3 mb-0 mt-2 border-top"></p>
<br><br>
<div class="row">
<div class="col">
<h3>Screening Questions</h3>
</div>
</div>
<br><br>
<div class="row">
<div class="col-3">
<label class="control-label" for="postalstate"><b>Q1</b></label>
</div>
<div class="col-3">
<input required type="text" style="width:300px" class="form-control" id="postalstate" name="postalstate" />
</div>
<div class="col-3">
<label class="control-label" for="fname"><b>Q2</b></label>
</div>
<div class="col-3">
<input required type="text" style="width:300px" class="form-control" id="LevelOfExperience" name="LevelOfExperience" />
</div>
</div>
<br><br>
<div class="row">
<div class="col-3">
<label class="control-label" for="postalstate"><b>Q3</b></label>
</div>
<div class="col-3">
<input required type="text" style="width:300px" class="form-control" id="postalstate" name="postalstate" />
</div>
<div class="col-3">
<label class="control-label" for="fname"><b>Q4</b></label>
</div>
<div class="col-3">
<input required type="text" style="width:300px" class="form-control" id="LevelOfExperience" name="LevelOfExperience" />
</div>
</div>
<br><br>
<p class="text-muted pt-3 mb-0 mt-2 border-top"></p>
<br>
<div class="row">
<div class="col-9"></div>
<div class="col-3 text-right">
<input type="button" class="btn-lg btn-outline-primary" value="Apply" onclick="SaveApplication();">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- online bootstrap -->
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2 poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft 2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script>
function getValue(radio) {
if ((radio.value) == 1) {
document.getElementById("postalone").style.display = "none";
document.getElementById("postaltwo").style.display = "none";
} else {
document.getElementById("postalone").style.display = "block";
document.getElementById("postaltwo").style.display = "block";
}
}
</script>
</body>
</html>
`
uj5u.com热心网友回复:
从列中洗掉样式标签并使用单个 div 标签并将所有输入放在其中。然后使用代码隐藏div。
<div id="postal" style="display: none;" >
<div class="row" >
<div class="col-3">
<labe
0 评论