2 Replies Latest reply on Feb 21, 2010 5:23 PM by venkatsyss

    Regarding - Checkbox Value

    venkatsyss Level 1

      hi,

       

      My question is how i get the selected checkbox value in the database in php.

       

      The following code shows

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="userRequest.send()">
      <mx:HTTPService id="userRequest" method="POST" useProxy="false" url="check.php" result="Display(event)">
          <mx:request xmlns="">
              <memid>{uRequest.selectedItem.userid}</memid>
          </mx:request>
      </mx:HTTPService>  

       

      <mx:Script>
          <![CDATA[
              import mx.events.ListEvent;
              import mx.rpc.events.ResultEvent;
              import mx.collections.ArrayCollection;
              import mx.controls.Alert;
              import mx.controls.DataGrid;
              [Bindable]private var arr:ArrayCollection;
              private function Display(event:ResultEvent):void{
                  arr=event.result.users.user;
                 
              }
              private function handleSelect(value:Boolean):void
                  {
                      userRequest.lastResult.users.user.source.forEach(
                          function callback(item:*, index:int, array:Array):void
                          {
                              item.sel = value;
                          });
                      userRequest.lastResult.users.user.refresh();
                  }
                  private function Update():void{
                      userRequest.send();
                  }
                   public function disp(event:ListEvent):void
                      {
                              var obj:Object=uRequest.selectedItem.userid;
                             // Alert.show("Checkbox=" + obj);

       


                      }

       

          ]]>
      </mx:Script>
      <mx:DataGrid dataProvider="{arr}" id="uRequest" itemClick="disp(event)">
      <mx:columns>
      <mx:DataGridColumn>
          <mx:itemRenderer>
          <mx:Component>
              <mx:CheckBox selected="{data.sel}">
                 
              </mx:CheckBox>
          </mx:Component>
      </mx:itemRenderer>

       

          </mx:DataGridColumn>
         
          <mx:DataGridColumn headerText="Sl.No" dataField="userid"></mx:DataGridColumn>
              <mx:DataGridColumn dataField="username">
                 
              </mx:DataGridColumn>
              <mx:DataGridColumn dataField="useremail">
                 
              </mx:DataGridColumn>
              <mx:DataGridColumn dataField="userstate">
                 
              </mx:DataGridColumn>
             
          </mx:columns>
         
      </mx:DataGrid>
      <mx:Button label="CheckAll" click="handleSelect(true)">
         
      </mx:Button>

       

      <mx:Button label="Update" click="Update()">
         
      </mx:Button>
      </mx:Application>

       

      Please provide me the solution to solve the problem.

       

      Thanks and Regards,

      venkat.R

        • 1. Re: Regarding - Checkbox Value
          archemedia Level 4

          The selected property of a checkBox should be of Boolean type. Passing 0 or 1 won't work.

           

          When binding a checkbox to a integer value, do this:

           

          <mx:CheckBox id="cb" selected="{Boolean(data.selected)}"/>

           

          When binding to a string, do this:

           

          <mx:CheckBox id="cb" selected="{Boolean(int(data.selected))}"/>

           

          When passing it back, do:

           

          data.selected = int(cb.selected);

           

          Dany

          • 2. Re: Regarding - Checkbox Value
            venkatsyss Level 1

            hi,

             

            Thanks for your kind reply.

             

            I am using itemrenderer  to display checkbox in the datagrid.if i put id in the checkbox it will shows the error,id is not a attribute.

             

            How i get multiple selected checkbox id in the httpservice.

             

            Please provide me the solutions to solve the problem.

             

             

            Thanks and Regards,

            venkat.R