簡體   English   中英

PHP如何在模式彈出窗口中打開常規選擇框選項而不是常規組合框

[英]Php how to open bootstrap selectbox options in modal popup not the regular combobox

我有常規的組合框,但是我不想像常規的那樣打開它,我想在打開組合框時打開模式彈出框,所有<option>應該在該模式彈出框中打開,我會從那里選擇選項。

我不知道如何用jquery或javascript或css做到這一點。

非常感謝您的幫助。

<select name="xyz">
i want to open the below option in modal popup to select from there.
<option>001</option>
<option>002</option>
<option>003</option>
</select>

你照你說的做。 您可以使用選項來構建模態,並且可以在單擊字段時打開模態。

您只需要一個按鈕,一個文本元素和一個隱藏的輸入即可。

<input type="hidden" id="option">
<button role="button" data-toggle="modal" data-target="#selectModal">
    Select an Option
</button>
<span id="optionName"></span>

該按鈕將觸發模態。 在模式中,您將單擊可用選項,然后單擊更新輸入值和文本元素的內容。

$(option).on('click', function () {
    $('#option').val($(this).attr('value'));
    $('#optionName').text($(this).text());
    $('#selectModal').modal('hide');
});

完整示例https://jsfiddle.net/orcjugj2/4/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM