Yii Framework Forum: Checkbox List... - Yii Framework Forum

Jump to content

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

Checkbox List... Rate Topic: -----

#1 User is offline   rajkumar000000 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 88
  • Joined: 18-September 12

Posted 21 February 2013 - 06:39 AM

hello friends....
i have a table tbl_pricing(product_id,price).
i use this code in the form
echo CHtml::activeCheckBoxList($model,'price',
CHtml::listData(Pricing::model()->findAll(), 'price', 'price'),	
array( 'template'=>'<li>{input} {label}</li>',  'class'=>'masterIndexFilter',)); 
		

i found that all price value come on checkbox in the view part.
but i want to take only 4 or 5 checkbox which takes all price value.
example 1. below 2000 one checkbox
2. 2001 to 5000 2nd checkbox
3. 5001 to 10000 3rd checkbox
is it possible,to take all value in 4 or 5 checkbox?
if yes please give me some suggestion .
thanks in advance.
0

#2 User is offline   rajkumar000000 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 88
  • Joined: 18-September 12

Posted 21 February 2013 - 08:02 AM

anyone please see it..
0

#3 User is offline   waterloomatt 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 545
  • Joined: 09-April 10

Posted 21 February 2013 - 12:05 PM

Sorry, couldn't quite understand your requirements. Are you looking for a way to display all possible amounts with 4-5 checkboxes?
  • Under $2,000
  • $2,001 - $5,000
  • $5,001 - $10,000
  • > $10,000

Matt
0

#4 User is offline   rajkumar000000 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 88
  • Joined: 18-September 12

Posted 22 February 2013 - 01:51 AM

View Postwaterloomatt, on 21 February 2013 - 12:05 PM, said:

Sorry, couldn't quite understand your requirements. Are you looking for a way to display all possible amounts with 4-5 checkboxes?
  • Under $2,000
  • $2,001 - $5,000
  • $5,001 - $10,000
  • > $10,000

Matt


actually i want to search the product from a range of price.
if i click the checkbox Under $2,000, then after all product search and display Under $2,000 value.
so firstly i want to create checkbox those takes this values,then after search the product.
0

#5 User is offline   mirunho 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 19-December 12
  • Location:Gdansk, Poland

Posted 22 February 2013 - 02:02 AM

View Postrajkumar000000, on 22 February 2013 - 01:51 AM, said:

actually i want to search the product from a range of price.
if i click the checkbox Under $2,000, then after all product search and display Under $2,000 value.
so firstly i want to create checkbox those takes this values,then after search the product.


I also dont know if i get You corectly but i think that You need 4 divs with every group of price and on click You should display one div and set other ones to display none. Am I right ?
0

#6 User is offline   rajkumar000000 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 88
  • Joined: 18-September 12

Posted 22 February 2013 - 03:26 AM

View Postmirunho, on 22 February 2013 - 02:02 AM, said:

I also dont know if i get You corectly but i think that You need 4 divs with every group of price and on click You should display one div and set other ones to display none. Am I right ?


thanks mirunho...

my scenario is exactly same as this external link .
here u watch in left side and see price.
i want to make a feature as same as this.
i have a table in which one column that name is "price".
here price of the all the product is present.
if i click on one range of price then it search all the product within that range.
please give me some suggestion...
0

#7 User is offline   mirunho 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 19-December 12
  • Location:Gdansk, Poland

Posted 22 February 2013 - 03:35 AM

View Postrajkumar000000, on 22 February 2013 - 03:26 AM, said:

thanks mirunho...

my scenario is exactly same as this external link .
here u watch in left side and see price.
i want to make a feature as same as this.
i have a table in which one column that name is "price".
here price of the all the product is present.
if i click on one range of price then it search all the product within that range.
please give me some suggestion...

My solution is like i said depends on checked input for checkboxes - hide/show divs with record with given price range.
very simple jquery code for that:
Yii::app()->clientScript->registerScript('formName', "".
        "$('#checkbox_id input').click(function(){".
	"var i = $(this).parent().index();".
	"if($(this).attr('checked')){".
		"$('#div_id').show();".
	"}else{".
		"$('#div_id').hide();".
	"}".
"});".
""); 

0

#8 User is offline   rajkumar000000 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 88
  • Joined: 18-September 12

Posted 22 February 2013 - 03:43 AM

View Postmirunho, on 22 February 2013 - 03:35 AM, said:

My solution is like i said depends on checked input for checkboxes - hide/show divs with record with given price range.
very simple jquery code for that:
Yii::app()->clientScript->registerScript('formName', "".
        "$('#checkbox_id input').click(function(){".
	"var i = $(this).parent().index();".
	"if($(this).attr('checked')){".
		"$('#div_id').show();".
	"}else{".
		"$('#div_id').hide();".
	"}".
"});".
""); 



thanks mirunho..
but how to take range of price value by the checkbox?
if i use this
echo CHtml::activeCheckBoxList($model,'price',
CHtml::listData(Pricing::model()->findAll(), 'price', 'price'), 
array( 'template'=>'<li>{input} {label}</li>',  'class'=>'masterIndexFilter',)); 

it takes individual price value.
how to take particular range of price value in form?
0

#9 User is offline   waterloomatt 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 545
  • Joined: 09-April 10

Posted 22 February 2013 - 07:19 AM

You can manually create an array of prices.

<?php
// Put these in your model
const RANGE_UNDER_2000 = '< 2000';
const RANGE_OVER_2000_AND_UNDER_5000 = '>= 2000 AND <= 5000';
const RANGE_OVER_5000_AND_UNDER_10000 = '> 5000 AND <= 10000';
const RANGE_OVER_10000 = '> 10000';

echo CHtml::activeCheckBoxList(
	$model,
	'price',
	array(
		Price::RANGE_UNDER_2000 => '< $2,000',
		Price::RANGE_OVER_2000_AND_UNDER_5000 => '$2,000 - $5,000',
		Price::RANGE_OVER_5000_AND_UNDER_10000 => '$5,001 - $10,000',
		Price::RANGE_OVER_10000 => '> $10,000'
	), 
	array(
		'template' => '<li>{input} {label}</li>',  
		'class' => 'masterIndexFilter'
	)
); ?>

You can then use the $_POST/$_GET values in your SQL.

Matt
0

#10 User is offline   rajkumar000000 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 88
  • Joined: 18-September 12

Posted 22 February 2013 - 09:29 AM

View Postwaterloomatt, on 22 February 2013 - 07:19 AM, said:

You can manually create an array of prices.

<?php
// Put these in your model
const RANGE_UNDER_2000 = '< 2000';
const RANGE_OVER_2000_AND_UNDER_5000 = '>= 2000 AND <= 5000';
const RANGE_OVER_5000_AND_UNDER_10000 = '> 5000 AND <= 10000';
const RANGE_OVER_10000 = '> 10000';

echo CHtml::activeCheckBoxList(
	$model,
	'price',
	array(
		Price::RANGE_UNDER_2000 => '< $2,000',
		Price::RANGE_OVER_2000_AND_UNDER_5000 => '$2,000 - $5,000',
		Price::RANGE_OVER_5000_AND_UNDER_10000 => '$5,001 - $10,000',
		Price::RANGE_OVER_10000 => '> $10,000'
	), 
	array(
		'template' => '<li>{input} {label}</li>',  
		'class' => 'masterIndexFilter'
	)
); ?>

You can then use the $_POST/$_GET values in your SQL.

Matt


thanks waterloomatt...
it takes only constant value not all..
if i select < 2000
then i want to fetch the data from table < 2000 all value.
for example:
if($price == < 2000)
	{
	$criteria->condition = "pricing.price  >= '$this->0' and pricing.price <= '$this->2000'";
}



how to write the condition and search the data in controller?
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