这里我想在json格式上创建数组,我做了所有的事情,但是我想要使用选项选择,我想要使用选项选择的位,我不能制作json格式的数组,我花了超过1小时这个但是我无法得到解决方案
Type

Current %>%
group_by(Location) %>%
mutate(Type = myFunction(Sick)
, Type = ifelse(Sick == 1
, ifelse(!is.na(Type)
, Type, "Short Term")
, ""))

答案 0 :(得分:0)
如果我理解得很好,你想要这样的东西吗?
我在这里使用select multiple.
做一个例子
function createJSON() {
result = [];
items=[];
$('.Check1:checked').each(function(){
items.push($(this).val());
});
//var mobile = $(this).val();
result.push({select:$('select').val(), multiselect:items});
console.log(result);
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<form method="POST">
<select multiple="multiple">
<option value="option1">1</option>
<option value="option2">2</option>
<option value="option3">3</option>
<option value="option4">4</option>
</select>
<div class="col-md-4" style="padding-left: 4px; padding-right: 4px;">
<li style="color: #333; font-size: 85%;">
<input type="checkbox" class="Check1" name="listing_type[]" value="Office Space"> Office Space
</li>
</div>
<div class="col-md-4" style="padding-left: 4px; padding-right: 4px;">
<li style="color: #333; font-size: 85%;">
<input type="checkbox" class="Check1" name="listing_type[]" value="Apartment"> Apartment
</li>
</div>
<div class="col-md-4" style="padding-left: 4px; padding-right: 4px;">
<li style="color: #333; font-size: 85%;">
<input type="checkbox" class="Check1" name="listing_type[]" value="Villament"> Villament
</li>
</div>
<div class="col-md-4" style="padding-left: 4px; padding-right: 4px;">
<li style="color: #333; font-size: 85%;">
<input type="checkbox" class="Check1" name="listing_type[]" value="Individual House"> Individual House
</div>
<div class="col-md-4" style="padding-left: 4px; padding-right: 4px;">
<li style="color: #333; font-size: 85%;">
<input type="checkbox" class="Check1" name="listing_type[]" value="Row House"> Row House
</div>
<input type="button" id="btn-submit" value="submit" onClick="createJSON()">
</form>
&#13;