Cutter,
Here is something that I wrote...
<cffunction name="GetUserData" access="public"
output="true" displayname="Get User Data" hint="display the form
the user will fill out to provide data about a User">
<!-- This function displays the form to be used to
provide data for a User (primarily for editing) -->
<!-- This function is not complete. Access
restriction code has not been added yet. -->
<cfargument name="Customer" type="numeric"
required="true" default="THIS.CustomerIndex"
displayname="Customer" hint="The Index of the Customer to which
the USer will be addaed (key into the Company table).">
<cfquery datasource="#REQUEST.dbSource#"
username="#REQUEST.dbUserName#" password="#REQUEST.dbPassword#"
name="GetCompanyInfo">
SELECT *
FROM Company
ORDER BY CompanyName
</cfquery>
<cfoutput>
<script language="JavaScript"
type="text/javascript">
function validateForm(form)
{
//This function goes
through each of the form fields and determines if an entry has
been made.
//If an entry has not been
made, it asks the user to confirm that the lack of entry was
intentional.
//If the user fails to
confirm, the function returns a false.
//Further modifications
may include for the requirement of certain fields.
//loop through each of the
input fields and make sure a response has been given for each.
for (var i = 0; i <
(form.elements.length - 1); i++)
{
if (form.elements
[i].value == "")
{
//if the
field is blank
form.elements[i].focus(); //set the focus to the field
if (!
window.confirm(form.elements[i].name + " does not have a value.
Is this what you want?"))
{
//ask for confirmation of intentionally leaving it out
return false;
//if confirmation fails (the user hit cancel) then return
false (preventing the submission)
}
} //end if
(form.elements[i].value == "")
} //end for loop
} //end function validateForm
function setEmployeeLogin()
{
formUserDataEntry.EmployeeLogin.value =
formUserDataEntry.EmployeeFirstName.substring(0,0) +
formUserDataEntry.EmployeeLastName;
}
function setEmployeePassword()
{
if
(formUserDataEntry.EmployeePassword1.value ==
formUserDataEntry.EmployeePassword2.value)
{
formUserDataEntry.EmployeePassword.value =
formUserDataEntry.EmployeePassword1.value
}
else
{
window.alert("Set
and Confirm entries of Password do not match. Please re-enter.");
formUserDataEntry.EmployeePassword1.value = "";
formUserDataEntry.EmployeePassword2.value = "";
formUserDataEntry.EmployeePassword1.focus();
}
}
</script>
<form id="formUserDataEntry"
name="formUserDataEntry" title="User Data Entry Form"
action="Customer.cfc?method=AddUser" method="post"
onSubmit="validateForm(this)">
<input id="inputUserIndex"
name="EmployeeIndex" title="Employee Index" type="hidden"
value="<cfif isDefined("THIS.UserIndex")
>#THIS.UserIndex#</cfif>" />
<label id="labelInputFirstName"
title="Label for First Name Input" for="EmployeeFirstName">First
Name: <input id="inputFirstName" name="EmployeeFirstName"
title="Employee First Name" type="text" size="12" maxlength="10"
onchange="setEmployeeLogin()" value="<cfif isDefined
("THIS.FirstName")>#THIS.FirstName#</cfif>" /></label>
<label
id="labelInputMiddleInitial" title="Label for Middle Initial
Input" for="EmployeeMiddleInitial">Middle Initial: <input
id="inputMiddleInitial" name="EmployeeMiddleInitial"
title="Employee Middle Initial" type="text" size="7" maxlength="5"
value="<cfif isDefined("THIS.MiddleInitial")
>#THIS.MiddleInitial#</cfif>" /></label>
<label id="labelInputLastName"
title="Label for Last Name Input" for="EmployeeLastName">Last
Name: <input id="inputLastName" name="EmployeeLastName"
title="Employee Last Name" type="text" size="17" maxlength="15"
onchange="setEmployeeLogin()" value="<cfif isDefined
("THIS.LastName")>#THIS.LastName#</cfif>" /></label>
<label id="labelInputTitle"
title="Label for Title Input" for="EmployeeTitle">Title: <input
id="inputTitle" name="EmployeeTitle" title="Employee Title"
type="text" size="27" maxlength="25" value="<cfif isDefined
("THIS.Title")>#THIS.Title#</cfif>" /></label>
<label id="labelInputEMail"
title="Label for EMail Input" for="EmployeeEMail">EMail: <input
id="inputEMail" name="EmployeeEMail" title="Employee EMail
Address" type="text" size="52" maxlength="50" value="<cfif
isDefined("THIS.EMail")>#THIS.EMail#</cfif>" /></label>
<label id="labelInputAIM"
title="Label for AIM Input" for="EmployeeAIMScreenName">AIM Screen
Name: <input id="inputAIM" name="EmployeeAIMScreenName"
title="Employee AIM Screen Name" type="text" size="17"
maxlength="15" value="<cfif isDefined("THIS.AIM")
>#THIS.AIM#</cfif>" /></label>
<label id="labelInputTelephone"
title="Label for Telephone Input"
for="EmployeeTelephone">Telephone: <input id="inputTelephone"
name="EmployeeTelephone" title="Employee Telephone" type="text"
size="17" maxlength="15" value="<cfif isDefined("THIS.Telephone")
>#THIS.Telephone#</cfif>" /></label>
<label id="labelSelectCustomer"
title="Label for Customer Select" for="Company">Customer:
<select id="inputCustomer"
name="Company" title="Customer" size="1">
<option
id="CompanyDefault" title="Company Default" value="0">Select a
Customer </option>
<cfloop
query="GetCompanyInfo">
<cfoutput>
<option
id="Company#CompanyIndex#" title="#CompanyName#"
value="#CompanyIndex#"<cfif isDefined("THIS.Customer")><cfif
#THIS.Customer# EQ #CompanyIndex#>
selected</cfif></cfif>>#CompanyName#</option>
</cfoutput>
</cfloop>
</select>
</label>
<label id="labelInputLogin"
title="Label for Login Input" for="EmployeeLogin">Login: <input
id="inputLogin" name="EmployeeLogin" title="Employee Login"
type="text" size="18" maxlength="16" value="<cfif isDefined
("THIS.Login")>#THIS.Login#</cfif>" /></label>
<label id="labelInputPassword1"
title="Label for Password1 Input"
for="EmployeePassword1">Password: <input id="inputPassword1"
name="EmployeePassword1" title="Employee Password" type="password"
size="17" maxlength="15"
onchange="javascript:formUserDataEntry.EmployeePassword2.focus()"
value="<cfif isDefined("THIS.Password")
>#THIS.Password#</cfif>" /></label>
<label id="labelInputPassword2"
title="Label for Password2 Input" for="EmployeePassword2">Confirm
Password: <input id="inputPassword2" name="EmployeePassword2"
title="Confirm Employee Password" type="password" size="17"
maxlength="15" onchange="setEmployeePassword()" value="<cfif
isDefined("THIS.Password")>#THIS.Password#</cfif>" /></label>
<input id="inputPassword"
name="EmployeePassword" title="Employee Password" type="hidden"
size="17" maxlength="15" value="<cfif isDefined("THIS.Password")
>#THIS.Password#</cfif>" />
<input id="inputRole"
name="EmployeeRole" title="Employee Role" type="hidden"
value="3" />
<label id="labelButtonSubmit"
title="Label for Submit Button" for="Submit"><button
id="buttonSubmit" name="Submit"
type="submit">Submit</button></label>
</form>
</cfoutput>
</cffunction>
Robert J. Polickoski
Senior Programmer, ISRD Inc.
(540) 842-6339
[EMAIL PROTECTED]
AIM - RobertJFP
---------- Original Message ----------------------------------
From: "Cutter (CF_Talk)" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Date: Mon, 09 Dec 2002 11:46:09 -0500
>Does anyone have an example of a CFComponent with a function that
>returns HTML formatted output. Trying to write a function that
performs
>a query based on specific arguments then outputs a select box
based upon
>the query results as well as some of the other arguments. I'd
like to
>make it a web service but not sure if possible. (Documentation
for this
>stuff seems kinda limited on MM, though I might just be looking
in the
>wrong places.)
>
>Cutter
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.