Javascript 如何通过选择单选按钮选项更改文本表单字段
我有两个选项1-假期2-长期现在我想在这里是当我从单选按钮中选择这些选项时,表单填充,表单有以下字段: 一季 2-日期 3-每日 每周4次 5-每月 现在,当我选择value longterm时,我想从弹出表单中只显示每月字段,如果我选择vacational,则应显示所有字段 My html,其中包括以下选项:Javascript 如何通过选择单选按钮选项更改文本表单字段,javascript,php,laravel,Javascript,Php,Laravel,我有两个选项1-假期2-长期现在我想在这里是当我从单选按钮中选择这些选项时,表单填充,表单有以下字段: 一季 2-日期 3-每日 每周4次 5-每月 现在,当我选择value longterm时,我想从弹出表单中只显示每月字段,如果我选择vacational,则应显示所有字段 My html,其中包括以下选项: <div class="m-b-10 m-t-10"> <label class="radio-inline">
<div class="m-b-10 m-t-10">
<label class="radio-inline">
<input type="radio" id="inlineCheckbox1" value="is_vacation" name="property_type" checked> Vacation
</label>
<label class="radio-inline">
<input type="radio" id="inlineCheckbox2" value="is_long_term" name="property_type"> Long Term
</label>
</div>
我需要为这个创建一个新的视图吗?或者可以用JS来完成。我想可以用JS来完成,但我不知道怎么做。需要你的帮助吗
非常感谢您的帮助
jQuery使用单选按钮显示隐藏元素
.盒子{
颜色:fff;
填充:20px;
显示:无;
边缘顶部:20px;
}
.red{背景:ff0000;}
.green{背景:228B22;}
.blue{背景:0000ff;}
标签{右边距:15px;}
$document.readyfunction{
$'input[type=radio]'。单击函数{
var inputValue=$this.attrvalue;
var targetBox=$.+inputValue;
$.box.nottargetBox.hide;
$targetBox.show;
};
};
红色
绿色
蓝色
你选择了红色单选按钮,所以我在这里
您选择了绿色单选按钮,所以我在这里
你选择了蓝色单选按钮,所以我在这里
您是否期待使用Js实现此功能?是的,如果可以使用Js实现,那么我的工作将是solvedonchange功能将解决此功能,但我对Js了解不多,所以您可以创建两个div,一个用于休假,另一个用于长期,并为其添加相应的控件。然后使用Js选择特定的电台btn隐藏和显示这些div使用css属性display:none和display:block我们可以聊天吗?谢谢分享,但我认为不同的场景我们可以聊天吗请让我清楚地解释我的问题我很乐意给你的答案打分新的在这里你能指导我如何聊天吗?
if ($search == "vacationRental") {
// $properties = Property::where('is_vacation', '=', 1)->get();
$properties = Property::where('status', '=', 1)->where('is_vacation', '=', 1)->get();
return view('admin.property.index')
->with('properties', $properties)
->with('seasons', $seasons);
} elseif ($search == "longTerm") {
// $properties = Property::where('is_long_term', '=', 1)->get();
$properties = Property::where('status', '=', 1)->where('is_long_term', '=', 1)->get();
return view('admin.property.index')
->with('properties', $properties)
->with('seasons', $seasons);
}