I am trying to write a piece of code to populate a dialog box, and I'm not quite sure of my next step (or even if it's possible). I've searched the FAQs and forums, but haven't found anything related to this.
I have a form with a select box. When an option is selected, I want the form to run a new query based on the value in the select box. If a record exists (there will only ever be one record), a dialog box (ie. a Javascript alert) is displayed with the contents of the query.
I have this so far (simplified for this forum):
I assume the next step is to run the query and display the dialog box when the select box value changes (using the onclick event in my code - this select box will have another function associated with the onchange event), but I'm not sure how to proceed. I'm reasonably familiar with CF, but a novice when it comes to JS.
Can anyone help?
Thanks, Helen
I have a form with a select box. When an option is selected, I want the form to run a new query based on the value in the select box. If a record exists (there will only ever be one record), a dialog box (ie. a Javascript alert) is displayed with the contents of the query.
I have this so far (simplified for this forum):
Code:
<HTML>
<HEAD>
<TITLE>Test code</TITLE>
<SCRIPT LANGUAGE = "JavaScript">
<!--
function displ()
{
if(document.LogCall.ct_id.options[0].value == true)
{
return false
}
else
{
<!--- "unknown code to perform query to populate dialog box?" --->
return true;
}
}
//-->
</SCRIPT>
</HEAD>
<BODY onLoad="document.TestCode.ct_id.focus();">
<CFQUERY NAME="qryCallTypes"
DATASOURCE="Helpdesk">
SELECT ct.id ct_id
, ct.description call_type
FROM call_types ct
WHERE ct.active = 'Y'
ORDER BY ct.description
</CFQUERY>
<FORM ACTION="TestAction.cfm"
METHOD="post"
NAME="TestCode" onclick="return displ();">
<TABLE WIDTH="100%">
<TR>
<TD WIDTH="20%" ALIGN="right" VALIGN="baseline">
<B>Call type:</B>
</TD>
<TD WIDTH="80%" ALIGN="left" VALIGN="baseline">
<SELECT NAME="ct_id"
CLASS="inputbox">
<OPTION></OPTION>
<CFOUTPUT QUERY="qryCallTypes">
<OPTION VALUE="#qryCallTypes.ct_id#">
#qryCallTypes.call_type#
</OPTION>
</CFOUTPUT>
</SELECT>
</TD>
</TR>
<TR>
<TD COLSPAN="2">
</TD>
</TR>
<TR>
<TD WIDTH="20%">
</TD>
<TD WIDTH="80%" ALIGN="left">
<INPUT TYPE="Submit"
NAME="Action"
CLASS="inputbutton"
VALUE=" Log call ">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
I assume the next step is to run the query and display the dialog box when the select box value changes (using the onclick event in my code - this select box will have another function associated with the onchange event), but I'm not sure how to proceed. I'm reasonably familiar with CF, but a novice when it comes to JS.
Can anyone help?
Thanks, Helen