Hi,
Thanks for your suggestions. I tried it and the code looks like this:
submit button code:
<mx:Button label="Save" click="addAnnouncement(event);cancel();"
styleName="saveButton"/>
addAnnouncement function code:
private function addAnnouncement(evt:Event):void{
var selArr:Array = [];
var oRequest:Object = new Object();
var idx:int;
var len:int = userRequest.lastResult.partners.partner.length;
for (idx=0; idx<len; idx++) {
if (checkBox[idx].selected) {
selArr.push(checkBox[idx].label);
}
}
var strPartners:String = selArr.join(",");
oRequest.strTitle = strTitle.text;
oRequest.strContent = strContent.text;
oRequest.cntAnnouncement = cntAnnouncement.text;
oRequest.dtmAssignmentDueDate =
dtmAssignmentDueDate.text;
oRequest.dtmOpenDate = dtmOpenDate.text;
oRequest.dtmCloseDate = dtmCloseDate.text;
oRequest.strPartners = strPartners;
Alert.show('partner'+ strPartners);
Alert.show('title'+oRequest.strTitle);
Alert.show('strContent'+oRequest.strContent);
Alert.show
('cntannouncement'+oRequest.cntAnnouncement);
userRequest.send(oRequest);
//userRequest.send();
}
httpservice code:
<mx:HTTPService id="userRequest"
url="http://localhost:8500/qry_Announcement.cfm" useProxy="false"
method="POST">
</mx:HTTPService>
When I execute, the alert shows all the values selected. but it is
not getting inserted into the table(DB).
Here is the cfm code:
<cfprocessingdirective pageencoding = "utf-8" suppressWhiteSpace
= "Yes">
<cfif isDefined("oRequest.strTitle") and isDefined
("oRequest.strContent") and oRequest.strTitle NEQ "">
<cfquery name="addAnnouncement" datasource="Flex">
INSERT INTO tblAnnouncement
(strTitle, strContent, dtmOpenDate,
dtmCloseDate, dtmAssignmentDueDate )
VALUES
(<cfqueryparam value="#oRequest.strTitle#"
cfsqltype="CF_SQL_VARCHAR" maxlength="150">,
<cfqueryparam value="#oRequest.strContent#"
cfsqltype="CF_SQL_LONGVARCHAR">,
<cfqueryparam value="#oRequest.dtmOpenDate#"
cfsqltype="CF_SQL_DATE">,
<cfqueryparam value="#oRequest.dtmCloseDate#"
cfsqltype="CF_SQL_DATE">,
<cfqueryparam value="#oRequest.dtmAssignmentDueDate#"
cfsqltype="CF_SQL_DATE">
)
</cfquery>
</cfprocessingdirective>
i'm stuck here..not sure, where to look for the bug..i do not see
any error..any help is really appreciated.
-NB
</cfif>
--- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]>
wrote:
>
> Yes. To go a bit further, while you can create the request object
> declaratively in mxml as you have done, it is dificult to debug
and not
> very flexible. Instead, remove mx:request tagg and do this in a
> function. There is some almost-code below.
>
>
>
> But, it is not clear from your post quite what you want to sent to
the
> server. The repeater will produce multiple check boxes. What is
the
> server expecting? A delimited list of values? If so, then
Repeater
> creates an array of references to repeated items that have an id
> property. You can reference each check box like this: checkBox[n],
where
> "n" is the index in the dataProvider.
>
>
>
> So, in a for loop, with length equal to the Repeater dataProvider,
get a
> reference to each checkbox. Build your return data structure as
needed.
> Then put that into the request object, like below.
>
>
>
> var oRequest:Object = new Object();
>
> oRequest. strTitle = strTitle.text;
>
> oRequest.strContent = strContent.text;
> oRequest.dtmAssignmentDueDate = dtmAssignmentDueDate.text;
>
> //oRequest.selected = See above??;
>
> userRequest.send(oRequest);
>
>
>
> Now,
>
>
>
> ________________________________
>
> From: [email protected]
[mailto:[EMAIL PROTECTED] On
> Behalf Of valdhor
> Sent: Friday, November 21, 2008 1:11 PM
> To: [email protected]
> Subject: [flexcoders] Re: checkbox usage in flex
>
>
>
> Instead of initiating send in the button, call a function. In the
> function, use the getRepeaterItem method of the repeated item to
get
> each checkbox value then add that as a parameter of the call.
>
> Check the help for more detail:
> http://livedocs.adobe.com/flex/3/html/help.html?
content=repeater_3.html
> <http://livedocs.adobe.com/flex/3/html/help.html?
content=repeater_3.html
> >
>
> --- In [email protected] <mailto:flexcoders%
40yahoogroups.com>
> , "sbnkn" <sbnkn@> wrote:
> >
> > Hi All,
> >
> > I'm new to Flex development and have strong CF background.
> >
> > My simple project detail:
> > I have a datagrid and a form (text field, textarea field,
datefield,
> > and checkbox). Once I provide all the information, and submit the
> > form, the data gets inserted into the table(SQL DB) and shows in
the
> > datagrid.
> >
> > All these work fine except, the checkbox. I use mx:HTTPService.
> >
> > My question: How do I pass the selected checkbox value(s) to the
> > httpservice.
> >
> > checkbox code:
> >
> > <mx:Repeater id="checkBoxRepeater"
> > dataProvider="{userRequest.lastResult.partners.partner}">
> > <mx:CheckBox id="checkBox"
> > label="{checkBoxRepeater.currentItem.strPartner}"
> > data="{checkBoxRepeater.currentItem.strPartner}"
> > />
> > </mx:Repeater>
> >
> > save button code:
> > <mx:Button label="Save" click="userRequest.send();cancel();"
> > styleName="saveButton"/>
> >
> > httpservice code:
> > <mx:HTTPService id="userRequest"
> > url="http://url.com/dispaly/qry_Annoucement.cfm
> <http://url.com/dispaly/qry_Annoucement.cfm> " useProxy="false"
> > method="POST">
> > <mx:request xmlns="">
> > <strTitle>{strTitle.text}</strTitle>
> > <strContent>{strContent.text}</strContent>
> >
> >
> <dtmAssignmentDueDate>{dtmAssignmentDueDate.text}
</dtmAssignmentDueDate>
> > <strPartners>{strPartners.text}</strPartners>
> > </mx:request>
> > </mx:HTTPService>
> >
> > Any help or direction will be great.
> >
> > Thanks for your help in advance,
> > NB
> >
>