0

我一直在搞乱这个小部件(http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/basic.htm)几个小时没有进展。我需要下拉菜单像上面链接中的第二个示例一样运行。截至目前,下拉菜单打开,当我点击复选框时,它会自动关闭。我可以使用键盘访问下拉列表的字段,然后按回车键将选择所需的选项。但是,当我用鼠标单击该选项时,整个下拉菜单会自行隐藏。此外,下拉列表位于其下方的其余联系表单之后。我尝试了 z-index 没有运气。提前谢谢你们,这让我发疯了。下面是我的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>#attributes.title#</title>
<META NAME="TITLE" CONTENT="#attributes.title#"/>
<META NAME="keywords" content="#attributes.keywords#" />
<META NAME="description" content="#attributes.description#" />
<script type="text/javascript" src="../ddcl/jquery-1.6.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="/jQuery/Fancy/style.css" />
<link rel="stylesheet" type="text/css" href="/jQuery/Fancy/jquery.fancybox-1.3.1.css">
<link rel="stylesheet" href="/Themes/PrintCenter/style.css" />
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/ui-lightness/jquery-ui.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<script type="text/javascript" src="../ddcl/jquery.multiselect.js"></script>
<cfinclude template="/Includes/header_head.cfm">
 </head>

和 HTML

<cfform action="/Task/Form/ProcessForm.cfm" id="print-request-form" method="post"     name="printrequestform"> 
 <span>Select Print Material</span>
  <select name="example-optgroup" multiple="multiple" size="5" id="dropdowns">
<optgroup label="Tri-Fold Brochure">
    <option value="option1">500 units</option>
    <option value="option2">1000 units</option>
    <option value="option3">1500 units</option>
</optgroup>
<optgroup label="Group Two">
    <option value="option4">500 units</option>
    <option value="option5">1000 units</option>
    <option value="option6">1500 units</option>
    <option value="option7">2000 units</option>
</optgroup>
</select><label><span>Full Name:</span> <cfinput class="input-text" maxlength="100" message="Please enter a valid name." name="name" required="yes" size="30" type="text" validate="maxlength"></cfinput></label></cfform>

剧本

<script type="text/javascript">
$("#dropdowns").multiselect({
selectedList: 2 // 0-based index
});</script>
4

2 回答 2

0

试试下面的代码。我已经创建了一个Fiddle示例供您查看它的实际应用。

你的很多页面html代码并没有直接连接到渲染Multiselect JQuery选择器的Grouped order的问题,所以我在下面的代码中省略了它:

<script type="text/javascript">
  $(function(){
     $("select").multiselect();
  });
</script>

<cfform action="/Task/Form/ProcessForm.cfm" id="print-request-form" method="post"     name="printrequestform">
    <h1>Optgroups Example</h1>
    <h3>ehynds / jquery-ui-multiselect-widget</h3>   
 <span>Select Print Material</span>
  <select name="example-optgroup" multiple="multiple" size="5" id="dropdowns">
<optgroup label="Tri-Fold Brochure">
    <option value="option1">500 units</option>
    <option value="option2">1000 units</option>
    <option value="option3">1500 units</option>
</optgroup>
<optgroup label="Group Two">
    <option value="option4">500 units</option>
    <option value="option5">1000 units</option>
    <option value="option6">1500 units</option>
    <option value="option7">2000 units</option>
</optgroup>
</select><label><span>Full Name:</span> <cfinput class="input-text" maxlength="100" message="Please enter a valid name." name="name" required="yes" size="30" type="text" validate="maxlength"></cfinput></label></cfform>

我希望这对您的问题和其他有类似问题的人有所帮助。

于 2014-03-08T01:23:50.303 回答
0

检查您的元素名称,当它说多个时,它必须是一个数组。

<select name="my_options[]" multiple class="multiselect">
于 2015-11-24T14:44:42.940 回答