Yii Framework Forum: activeCheckBox click on checkbox but still marked as unchecked and not change in $_POST - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

activeCheckBox click on checkbox but still marked as unchecked and not change in $_POST Creating a dependent checkbox Rate Topic: -----

#1 User is offline   kashan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 02-February 12

Posted 08 February 2012 - 10:40 AM

I want to load data depending on checkbox and try in this way.

echo CHtml::activeCheckBox($model,'State',
array('ajax'=>array('url'=>$this->createUrl('ad/AllState'),'type'=>'POST')));

When I checked the checkbox then
there are two issues

1) Checkbox always marked as unchecked.
2) Wrong value in $_POST.
0

#2 User is offline   Maurizio Domba 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,228
  • Joined: 12-October 09
  • Location:Croatia

Posted 08 February 2012 - 04:12 PM

Please explain more the issue... how and when do you check the checkbox... what you mean with checkbox always marked as unchecked... if you click on the checkbox does it get checked?

what values do you get in $_POST and what values should be there ?
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   kashan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 02-February 12

Posted 09 February 2012 - 07:08 AM

View Postmdomba, on 08 February 2012 - 04:12 PM, said:

Please explain more the issue... how and when do you check the checkbox... what you mean with checkbox always marked as unchecked... if you click on the checkbox does it get checked?

what values do you get in $_POST and what values should be there ?


If I click on checkbox it does not checked.
I got 1 in $_POST.
Value should be 0 if unchecked and 1 if checked.


here is my requirement

I visited my form.
there are three checkboxes.(see attachment)
requirement is when user click on state filter checkbox then load data.

I am trying to use activeCheckBox for this.
I click on state filter checkbox many time but checkbox always unchecked and it sent request to controller and every time I got the value of checkbox as 1 in $_POST.


If there is a solution for our requirement please refer

Attached File(s)


0

#4 User is offline   Maurizio Domba 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,228
  • Joined: 12-October 09
  • Location:Croatia

Posted 09 February 2012 - 08:39 AM

Problem is the "ajax" usage... when you click the checkbox an ajax request is made for that checkbox... as you clicked it... the value of the checkbox is 1... but that is not shown on the display because by default false is returned from the ajax call...
Find more about me.... btw. Do you know your WAN IP?
0

#5 User is offline   kashan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 02-February 12

Posted 09 February 2012 - 09:33 AM

View Postmdomba, on 09 February 2012 - 08:39 AM, said:

Problem is the "ajax" usage... when you click the checkbox an ajax request is made for that checkbox... as you clicked it... the value of the checkbox is 1... but that is not shown on the display because by default false is returned from the ajax call...


Can you tell me the changes in my code?
0

#6 User is offline   Maurizio Domba 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,228
  • Joined: 12-October 09
  • Location:Croatia

Posted 13 February 2012 - 07:12 AM

I explained you above what is going on here...

To solve this... 2 possibilities comes to mind...

One would be to use a custom ajax code so that you do not return false at the end...

Second would be to update the checkboxes on ajax calls...
Find more about me.... btw. Do you know your WAN IP?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users