I have two option 1- Vacational 2- Longterm Now what I want here is when I select these option from radio buttons form is populated and form has following fields:
1- Season 2- Dates 3- Daily 4- Weekly 5- Monthly
Now what I want here when I select value longterm I want to display only Monthly field from popup form and if I select vacational all the fields should be displayed.
My html where these options are:
<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>
and my controller
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);
}
do I need to create a new view for this or it can be done with JS I think it can be done with JS but I don't have an idea how to do this. need your help
Your help will be highly appreciated!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Show Hide Elements Using Radio Buttons</title>
<style type="text/css">
.box{
color: #fff;
padding: 20px;
display: none;
margin-top: 20px;
}
.red{ background: #ff0000; }
.green{ background: #228B22; }
.blue{ background: #0000ff; }
label{ margin-right: 15px; }
</style>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('input[type="radio"]').click(function(){
var inputValue = $(this).attr("value");
var targetBox = $("." + inputValue);
$(".box").not(targetBox).hide();
$(targetBox).show();
});
});
</script>
</head>
<body>
<div>
<label><input type="radio" name="colorRadio" value="red"> red</label>
<label><input type="radio" name="colorRadio" value="green"> green</label>
<label><input type="radio" name="colorRadio" value="blue"> blue</label>
</div>
<div class="red box">You have selected <strong>red radio button</strong> so i am here</div>
<div class="green box">You have selected <strong>green radio button</strong> so i am here</div>
<div class="blue box">You have selected <strong>blue radio button</strong> so i am here</div>
</body>
</html>
Here is a Sample Example you can refer
</div>