Показать сообщение отдельно
  #4 (permalink)  
Старый 13.11.2015, 01:21
Профессор
Отправить личное сообщение для Mess4me Посмотреть профиль Найти все сообщения от Mess4me
 
Регистрация: 03.11.2014
Сообщений: 263

Ambassador,
так нормально?
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <script src="//code.jquery.com/jquery-1.11.3.min.js"></script>

    <title></title>
</head>
<body>
<div>
    <!--<img id="image" src="http://cdn3.vox-cdn.com/uploads/chorus_asset/file/917470/iphone-6-travel-photo-review-mann-header.0.jpg">-->
</div>
<script>

    var AllValue = new Array(
            {"ID":"4"},
            {"TITLE":"Сделка1"},
            {"UF_CRM_1443646396":"2015-09-01T23:22:00+03:00"},
            {"UF_CRM_1443646416":"1000"},
            {"UF_CRM_1443646449":"2015-09-03T23:22:00+03:00"},
            {"UF_CRM_1443646467":"3500"},
            {"ID":"5"},
            {"TITLE":"Сделка2"},
            {"UF_CRM_1443646467":"2015-05-30T23:22:00+03:00"},
            {"UF_CRM_1443646416":"1500"},
            {"UF_CRM_1444076242":"2015-03-24T23:22:00+03:00"},
            {"UF_CRM_1444076259":"4500"}
    );

    var myTwoArray = new Array(
            {"ID":"150","ENTITY_ID":"CRM_DEAL","FIELD_NAME":"UF_CRM_1443646396","USER_TYPE_ID":"datetime"},
            {"ID":"152","ENTITY_ID":"CRM_DEAL","FIELD_NAME":"UF_CRM_1443646416","USER_TYPE_ID":"double"},
            {"ID":"154","ENTITY_ID":"CRM_DEAL","FIELD_NAME":"UF_CRM_1443646449","USER_TYPE_ID":"datetime"},
            {"ID":"156","ENTITY_ID":"CRM_DEAL","FIELD_NAME":"UF_CRM_1443646467","USER_TYPE_ID":"double"},
            {"ID":"158","ENTITY_ID":"CRM_DEAL","FIELD_NAME":"UF_CRM_1444076242","USER_TYPE_ID":"datetime"},
            {"ID":"160","ENTITY_ID":"CRM_DEAL","FIELD_NAME":"UF_CRM_1444076259","USER_TYPE_ID":"double"}
    );

    var lastID, lastTitle;
    var newArr = [];
    $.each(AllValue, function (index, obj) {
        for(var key in obj){


            var value = obj[key]; // values of AllValues array
            if(key == "ID") lastID = value;
            if(key == "TITLE") lastTitle = value;

                for (var key1 in myTwoArray) { //
                var obj1 = myTwoArray[key1]; // values of myTwoArray array

                if(obj1.FIELD_NAME == key){
                    newArr.push({
                        id: lastID,
                        title: lastTitle,
                        fieldName: obj1.FIELD_NAME
                    })


                }


            }

        }
    });

   alert(JSON.stringify(newArr));

 
</script>

</body>
</html>

Последний раз редактировалось Mess4me, 13.11.2015 в 02:02.
Ответить с цитированием