我需要使用HTML,JavaScript和JQuery創建增強傳輸框。如何使用屬性創建增強的HTML傳輸框
我有一組用戶可以選擇並與屬性相關聯的選項。選擇和取消選擇必須用兩個SELECT HTML元素(即傳輸箱)完成。例如,這些選項可以是技能名稱列表。
當單擊「添加」按鈕時,第一個SELECT元素中選定的選項以及屬性(例如文本框中的年數)必須從源SELECT元素傳輸到選定/目的地SELECT元素。該屬性必須與第二個SELECT元素中的項目文本一起顯示(例如,該項目顯示技能和年數)。
當單擊「刪除」按鈕時,第二個SELECT元素中的選定選項必須移回到第一個SELECT元素(原始格式..沒有該屬性)。
JSON應該是初始選擇設置和保存最新選擇的數據格式。
我想要在隱藏的輸入字段中通過JSON設置一組初始選擇和屬性。我希望將最後一組選擇保存到JSON中的相同隱藏輸入字段中。
例HTML:
<input type="hidden" id="SelectionsId" value='[{ "id": "2", "attribute":"15"},{ "id": "4", "attribute":"3" }]' />
<!--<input type="hidden" id="SelectionsId" value='[]' />-->
<div>
<select class="MultiSelect" multiple="multiple" id="SelectFromId">
<option value="1">.NET</option>
<option value="2">C#</option>
<option value="3">SQL Server</option>
<option value="4">jQuery</option>
<option value="5">Oracle</option>
<option value="6">WPF</option>
</select>
<div style="float:left; margin-top:3%; padding:8px;">
<div>
<span>Years:</span>
<input id="YearsId" type="number" value="1" style="width:36px;" />
<button title="Add selected" id="includeBtnId">⇾</button>
</div>
<div style="text-align:center;margin-top:16%;">
<button title="Remove selected" id="removeBtnId">⇽</button>
</div>
</div>
<select class="MultiSelect" multiple="multiple" id="SelectToId"></select>
</div>
<div style="clear:both;"></div>
<div style="margin-top:40px;margin-left:200px;">
<button onclick="SaveFinalSelections();">Save</button>
</div>
實施例的CSS:
<style>
.MultiSelect {
width: 200px;
height: 200px;
float: left;
}
</style>
視覺的要求:
**您試圖自答案,同時**提問時間:'2017年12月3日01:58:32Z' 回答時間:2017年' -12-03 01:58:32Z'。 –