Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Создаем 2 инфоблока, связываем их, по ID
- #Создаем 2 пользовательских свойства, тип привязка к эл. инфоблока
- #js код
- Array.prototype.in_array = function(needle) {
- for(var i = 0, l = this.length; i < l; i++) {
- if(this[i] == needle) {
- return true;
- }
- }
- return false;
- }
- $(document).ready(function(){
- $("select[name=UF_CLASSIFICATION] option").hide();
- $("select[name=UF_CLASSIFICATION]").attr("disabled","disabled");
- /*Classification*/
- $("select[name=UF_CATEGORY]").change(function(){
- var categoryId = $(this).val();
- var dataAjax = {};
- dataAjax["categoryId"] = categoryId;
- $.ajax({
- type:'POST',
- url:'/local/ajax/support_classification.php',
- success:function(data){
- $("select[name=UF_CLASSIFICATION]").removeAttr("disabled");
- $("select[name=UF_CLASSIFICATION] option").each(function(){
- var val = parseInt($(this).attr("value"));
- if(!data.in_array(val)){
- $(this).hide();
- }else{
- $(this).show();
- }
- });
- },
- data:dataAjax,
- dataType:'json'
- });
- });
- });
- #PHP код
- <?
- require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
- CModule::IncludeModule("iblock");
- $cID = $arr["VALUE"];
- $objClassification = CIBlockElement::GetList(
- array("ID"=>"ASC"),
- Array("IBLOCK_ID" => 38, "PROPERTY_ID" => intval($_REQUEST["categoryId"])),
- false,
- false,
- Array("ID", "NAME", "IBLOCK_ID",)
- );
- while($arrClassification = $objClassification->Fetch()){
- $arClassification[] = $arrClassification["ID"];
- }
- echo json_encode($arClassification);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement