사용자가 누를 때마다 새 드롭 다운 목록이 작성되고 선택한 값이 표시되지 않도록 추가 단추를 작성해야합니다. 새로운 dpl에서. 또한 첫 번째 드롭 다운 목록은 데이터베이스에서 데이터를 가져 오는 것입니다 (이것이 완료되었습니다).새 드롭 다운 목록을 만들고 새 dpl에서 선택한 값을 제거하는 버튼을 추가하십시오.
[예제] [1]을 시도했지만 작동하지 않습니다! 어떤 팁? 이 exacly 무엇을 경우
또한,이 검증 등 등
HTML 코드
<div id="services-D" class="oneField" >
<label id="services-L" for="services" class="label preField reqMark" style="width: 100px; min-width:0">Services</label><br>
<select id="c_service" name="c_service" class="required dynamic-select" style="width:170px" >
<option value="">Select Service...</option>
<?php
$res=mysqli_query($dbc,"Select t1 t2 Where t4s = 'Y'");
while ($row = mysqli_fetch_array($res)) { ?>
<option value = <?php echo $row['invoice_code']?> > <?php echo $row['t1'] . ": " . $row['t2'];}?> </option>
?>
</select>
</div>
<button type="button" id="btn_add_service" style="">Add Service</button>
에 대한 그래서 필요가 연습 jQuery를
<script>
$('#btn_add_service').on('click', function() {
selected = $('#c_service').prop('selectedIndex');
if (selected != 0 && $('#c_service').find('option').length != 2){
newselector = $('<select id="c_service"></select>').insertAfter('#c_service');
$('#c_service').find('option').each(function(index,item) {
if (index != selected){
$(newselector).append(item);
}
});
}
});
</script>
무엇'선택 값 '? 일부 HTML, JavaScript를 공유하여 문제를 예시하십시오. –
지금 확인하십시오 @AlanLarimer – noel293