Checkbox List...

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.

anyone please see it…

Sorry, couldn’t quite understand your requirements. Are you looking for a way to display all possible amounts with 4-5 checkboxes?

[list=1][]Under $2,000[]$2,001 - $5,000[]$5,001 - $10,000[]> $10,000[/list]

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.

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 =facets.price_range%255B%255D%3DRs.%2B2001%2B-%2BRs.%2B5000&layout=grid"]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();".

	"}".

"});".

""); 

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?

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?