简体   繁体   English

PHP如何在模式弹出窗口中打开常规选择框选项而不是常规组合框

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

I have the regular combobox but i dont want to open it like regular i want to open the modal popup when i click on combobox to open and the all <option> should me open in that modal popup and i will select options from there. 我有常规的组合框,但是我不想像常规的那样打开它,我想在打开组合框时打开模式弹出框,所有<option>应该在该模式弹出框中打开,我会从那里选择选项。

I donnot know that how to make it with jquery or javascript or using css. 我不知道如何用jquery或javascript或css做到这一点。

Your help will be highly appreciated. 非常感谢您的帮助。

<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>

You do as you said. 你照你说的做。 You build a modal with your options and have a way to open the modal when you click the field. 您可以使用选项来构建模态,并且可以在单击字段时打开模态。

All you need is a button a text element and a hidden input. 您只需要一个按钮,一个文本元素和一个隐藏的输入即可。

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

The button will trigger the modal. 该按钮将触发模态。 In the modal, you will have your available options clickable and on click update the value of the input and the content of the text element. 在模式中,您将单击可用选项,然后单击更新输入值和文本元素的内容。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM