Coldfusion 10 Dynamic从Microsoft SQL中选择

时间:2015-04-10 17:09:51

标签: jquery drop-down-menu coldfusion

我在ColdFusion中创建了一些动态下拉选择菜单。我想根据通过JQuery DatePicker(SpeakDate)输入的日期填充选择菜单。但是,我遇到的问题是我的查询中的SpeakDate在我的表单中未定义。任何帮助将不胜感激。

<head>
    <link type="text/css" rel="stylesheet" href="css/jquery-ui.css">
    <script src="js/jquery.js"></script>
    <script src="js/jquery-ui.js"></script>
    <script>
    $(function() {
      $( "#datepicker" ).datepicker();
    });
    </script>

    <cfquery name="getAgenda" 
        datasource="SpeakerCard"> 
        SELECT ItemNo 
        FROM tbl_AgendaList
        WHERE MeetingDate = '(#Form.SpeakDate#)'
    </cfquery> 
</head>

<cfoutput>
    <cfform id="Form" action="Card.cfm" method="post"> 
    <p>Date: <input type="text" id="datepicker" name="SpeakDate"><p>

    <p>Agenda Item: 
    <cfselect query="getAgenda"
        name="ItemNo" 
        value="ItemNo"> 
    </cfselect>
    </cfform>
</cfoutput>

1 个答案:

答案 0 :(得分:0)

这远非最佳解决方案,但它可能会产生您正在寻找的结果。

<head>
<link type="text/css" rel="stylesheet" href="css/jquery-ui.css">
<script src="js/jquery.js"></script>
<script src="js/jquery-ui.js"></script>
<script>
$(function() {
  $( "#datepicker" ).datepicker();
});
</script>
<cfif structKeyExists(Form,"SpeakDate")>
    <cfquery name="getAgenda" 
        datasource="SpeakerCard"> 
        SELECT ItemNo 
        FROM tbl_AgendaList
        WHERE MeetingDate = '(#Form.SpeakDate#)'
    </cfquery>
</cfif>
</head>

<cfoutput>
<cfform id="Form" action="Card.cfm" method="post"> 
<p>Date: <input type="text" id="datepicker" name="SpeakDate"><p>

<p>Agenda Item: 
<cfif isDefined("getAgenda")>
    <cfselect query="getAgenda"
        name="ItemNo" 
        value="ItemNo"> 
    </cfselect>
</cfif>
</cfform>