我想在用户选择“是”单选按钮后创建多组可选文本字段。现在,我为“身体残疾”创建了单选按钮和可选文本字段。我想为“健康问题”创建另一套。
当我创建另一个具有相同名称的函数时,只有最新的函数有效,第一个函数不起作用。我知道最后一个函数有点覆盖了早期的函数。
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<style></style>
</head>
<body>
{{-- javascript code for radio button and text field for Physical Disability --}}
<script type="text/javascript">
function ShowHideDiv() {
var chkYes = document.getElementById("chkYes");
var dvPhyDis = document.getElementById("dvPhyDis");
dvPhyDis.style.display = chkYes.checked ? "block" : "none";
}
</script>
{{-- javascript code for radio button and text field for Health Issue --}}
<script type="text/javascript">
function ShowHideDiv() {
var chkYes = document.getElementById("chkYes");
var dvHealthIss = document.getElementById("dvHealthIss");
dvHealthIss.style.display = chkYes.checked ? "block" : "none";
}
</script>
@extends('layout.basiclayout')
@section('content')
<h1>ADDITIONAL INFORMATION</h1>
{!! Form::open(['url' => 'page8/submit']) !!}
<span><b>Do you have any Physical Disability?</b></span>
<label for="chkYes">
<input type="radio" id="chkYes" name="chkPhyDis" onclick="ShowHideDiv()" value="Yes"/> Yes
</label>
<label for="chkNo">
<input type="radio" id="chkNo" name="chkPhyDis" onclick="ShowHideDiv()" value="No"/> No
</label>
<div id="dvPhyDis" style="display: none">
<b>Please provide more details:</b>
<input type="text" name="txtPhyDis" size="75px">
</div>
<br>
<span><b>Do you have any Health Issue?</b></span>
<label for="chkYes">
<input type="radio" id="chkYes" name="chkHealthIss" onclick="ShowHideDiv()" />
Yes
</label>
<label for="chkNo">
<input type="radio" id="chkNo" name="chkHealthIss" onclick="ShowHideDiv()" />
No
</label>
<div id="dvHealthIss" style="display: none">
<b>Please provide more details:</b>
<input type="text" name="txtHealthIss" size="75px">
</div>
<br>
<div class="form-group">
{{Form::submit('Submit', ['class' => 'btn btn-primary'])}}
</div>
{!! Form::close() !!}
</body>
</html>
@endsection