GroupBrowser  




Go Back   GroupBrowser > Macromedia Newsgroups > Coldfusion > Coldfusion General Discussion
User Name
Password
 
 
Thread Tools Search this Thread Display Modes

How to Insert Blank Record in Array?
Old 08-28-2008, 01:55 PM #1
Art of Zen
Guest
 
Status:
Posts: n/a
Default How to Insert Blank Record in Array?

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[i][1]=data.id[i]>
<cfset result[i][2]=data.name[i]>
</cfloop>
<!--- And return it --->
<cfreturn result >
</cffunction>

Code for select list:


<cfselect name="Contacts"
bind="cfc:getPartners.getUsers({mediaid})"
tooltip="Select Partner Rep" onError=""
width="50"/>


  Reply With Quote

Re: How to Insert Blank Record in Array?
Old 08-28-2008, 02:02 PM #2
Azadi
Guest
 
Status:
Posts: n/a
Default Re: How to Insert Blank Record in Array?

1) style="width:50px;"

2)
<cfif data.recordcount>
<cfset result[1][1] = "">
<cfset result[1][2] = "">
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.recordcount#">
<cfset result[i+1][1]=data.id[i]>
<cfset result[i+1][2]=data.name[i]>
</cfloop>
</cfif>

hth

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
  Reply With Quote

Re: How to Insert Blank Record in Array?
Old 08-28-2008, 03:39 PM #3
Dan Bracuk
Guest
 
Status:
Posts: n/a
Default Re: How to Insert Blank Record in Array?

Change this:

SELECT ID, NAME, ACCOUNTID__C
FROM DATA1
WHERE ACCOUNTID__C = '#arguments.accountID#'

to this
select distinct '' id, '' name, '' accountid_c
from some_small_table
union
SELECT ID, NAME, ACCOUNTID__C
FROM DATA1
WHERE ACCOUNTID__C = '#arguments.accountID#'
order by id

if any of those fields are not text, use whatever db function is appropriate
to convert to string in the bottom half of the query

  Reply With Quote

Re: How to Insert Blank Record in Array?
Old 08-28-2008, 07:29 PM #4
Art of Zen
Guest
 
Status:
Posts: n/a
Default Re: How to Insert Blank Record in Array?

Thank you! This was the answer for inserting that blank record!
  Reply With Quote

Re: How to Insert Blank Record in Array?
Old 08-28-2008, 07:31 PM #5
Art of Zen
Guest
 
Status:
Posts: n/a
Default Re: How to Insert Blank Record in Array?

Thanks for the style answer! the array did not work, but your solution for adding a style to the select certainly helped!
  Reply With Quote
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes





Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump




Adobe Newsgroups | Software Newsgroups


Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
© 2003-2004 All Rights Reserved GroupBrowser LLC.