Answered
How to Insert Blank Record in Array?
I assume that I need to insert a blank record into my array
to solve the problems below, but am not sure how to do so.
I have a function shown below that is part of a two selects related Component. My first problem is if no data is passed to the argument, the select field bound to the function is very tiny (I would like it to have a default width). Adding a "width" does not work.
SECONDLY, if there is data passed to the argument (in Arguments.accountID, i would like to have a blank record inserted at the top of the select list results. So in summary, if no data is passed to the argument, the select field is very small. If data is passed to the argument, the select list is populated, but I need to have a blank record (option) at the top of the select list.
The code for the function shown below:
<cffunction name="getUsers" access="remote" returnType="array">
<cfargument name="accountID" type="string" required="yes">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<cfset data1= oSF.QueryObject("select ID , name, Email, ACCOUNTID__C from User").results>
<cfquery dbtype="query" name="data">
SELECT ID, NAME, ACCOUNTID__C
FROM DATA1
WHERE ACCOUNTID__C = '#arguments.accountID#'
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.recordcount#">
<cfset result [1]=data.id>
<cfset result [2]=data.name>
</cfloop>
<!--- And return it --->
<cfreturn result >
</cffunction>
<b>Code for select list:</b>
<cfselect name="Contacts"
bind="cfc:getPartners.getUsers({mediaid})" tooltip="Select Partner Rep" onError=""
width="50"/>
I have a function shown below that is part of a two selects related Component. My first problem is if no data is passed to the argument, the select field bound to the function is very tiny (I would like it to have a default width). Adding a "width" does not work.
SECONDLY, if there is data passed to the argument (in Arguments.accountID, i would like to have a blank record inserted at the top of the select list results. So in summary, if no data is passed to the argument, the select field is very small. If data is passed to the argument, the select list is populated, but I need to have a blank record (option) at the top of the select list.
The code for the function shown below:
<cffunction name="getUsers" access="remote" returnType="array">
<cfargument name="accountID" type="string" required="yes">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<cfset data1= oSF.QueryObject("select ID , name, Email, ACCOUNTID__C from User").results>
<cfquery dbtype="query" name="data">
SELECT ID, NAME, ACCOUNTID__C
FROM DATA1
WHERE ACCOUNTID__C = '#arguments.accountID#'
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.recordcount#">
<cfset result [1]=data.id>
<cfset result [2]=data.name>
</cfloop>
<!--- And return it --->
<cfreturn result >
</cffunction>
<b>Code for select list:</b>
<cfselect name="Contacts"
bind="cfc:getPartners.getUsers({mediaid})" tooltip="Select Partner Rep" onError=""
width="50"/>
