我有多個選擇下拉菜單和多個div具有相同的類。 每個div都有一個下拉菜單和一個帶有類.dz文件名的div。jquery選擇下拉列表(數組)選項更改從div類獲取值
通過上傳圖像>文件名文本進入div與類.dz文件名和該圖像,您可以選擇一種格式。我想根據選擇將圖像與格式鏈接起來。
我怎樣才能得到文本里面的div與類.dz文件名,並將此文本填入選項值?
提交表格後,我想用PHP來看看哪些格式鏈接到圖像
例如:我希望
$(document).ready(function() {
$(".dz-select-system").change(function(){
var filename = $(".dz-filename span").text();
alert(filename);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="file_upload_container" class="dropzone dz-clickable dz-started dz-max-files-reached">
<div class="upload">
<div class="dz-filename">
<span data-dz-name="">banner.jpg</span>
</div>
<input type="hidden" class="picture_upload" name="picture_upload[]">
<select class="dz-select-system" style="width: 100%;margin-top: 10px;" name="format[]">
\t <option selected="" disabled="" value="-1">Selecteer uw formaat</option>
\t <option value="{HERE FILENAME IF THIS OPTION IS SELECT BY USER banner.jpg}">100 x 100, Geen, 1</option>
<option value="{HERE FILENAME IF THIS OPTION IS SELECT BY USER banner.jpg}">80 x 80, Geen, 1</option>
<option value="{HERE FILENAME IF THIS OPTION IS SELECT BY USER banner.jpg}">50 x 50, Geen, 1</option>
<option value="{HERE FILENAME IF THIS OPTION IS SELECT BY USER banner.jpg}">70 x 70, Geen, 1</option>
</select>
</div>
<div class="upload">
<div class="dz-filename">
<span data-dz-name="">photobanner1.jpg</span>
</div>
<input type="hidden" class="picture_upload" name="picture_upload[]">
<select class="dz-select-system" style="width: 100%;margin-top: 10px;" name="format[]">
<option selected="" disabled="" value="-1">Selecteer uw formaat</option>
\t <option value="{HERE FILENAME IF THIS OPTION IS SELECT BY USER photobanner1.jpg}">100 x 100, Geen, 1</option>
<option value="{HERE FILENAME IF THIS OPTION IS SELECT BY USER photobanner1.jpg}">80 x 80, Geen, 1</option>
<option value="{HERE FILENAME IF THIS OPTION IS SELECT BY USER photobanner1.jpg}">50 x 50, Geen, 1</option>
<option value="{HERE FILENAME IF THIS OPTION IS SELECT BY USER photobanner1.jpg}">70 x 70, Geen, 1</option>
</select>
</div></div>
將監聽器綁定到文件輸入onchange事件,獲取這些選項並設置value屬性。 –