2017-08-03 59 views
-5

我想創建其中可以提交值作爲以下格式如何形成的輸入端上形式的陣列提交

[ 
    { 
     "_id": "59817f39808768495728ae94", 
     "updatedAt": "2017-08-02T07:33:00.578Z", 
     "createdAt": "2017-08-02T07:28:57.310Z", 
     "farmId": "tesform", 
     "farmName": "tesform", 
     "gatewayId": "123", 
     "gatewayName": "testform getway", 
     "userId": "[email protected]", 
     "description": "test details 1st time",   
     "nodes": [ 
      { 
       "permanentAddress": "", 
       "description": "with temparature", 
       "name": "Node 1", 
       "_id": "5981802c808768495728ae9b", 
       "sensors": [ 
        { 
         "units": "C", 
         "max": 60, 
         "min": -6, 
         "name": "temparature", 
         "_id": "5981802c808768495728ae9c" 
        } 
       ], 
       "shortAddress": 0 
      }, 
      { 
       "permanentAddress": "", 
       "description": "with soil moisture and voltage", 
       "name": "Node 2", 
       "_id": "5981802c808768495728ae98", 
       "sensors": [ 
        { 
         "units": "C", 
         "max": 60, 
         "min": -6, 
         "name": "moisture", 
         "_id": "5981802c808768495728ae9a" 
        }, 
        { 
         "units": "C", 
         "max": 60, 
         "min": -6, 
         "name": "voltage", 
         "_id": "5981802c808768495728ae99" 
        } 
       ], 
       "shortAddress": 0 
      } 
     ] 
    } 
] 

我想創建動態地使用jquery節點和傳感器的形式。每個場應該有多個節點,並且每個節點可以有多個傳感器。

+0

我 –

+1

你需要大幅度擴大這個問題沒有真正得到你的問題。如果你想要有人幫助你 - 那就需要有一個明確的問題。您在提交表單時遇到問題嗎?創建表單?在您的後端接收數據?這是真的不清楚,應該儘快延長。 – Terrance00

+0

提供的HTML表單太 –

回答

0

可以以不同的電平輸入不同的類名稱添加,然後他們每個人,當來到交叉節點,將節點添加到對象,當來到交叉於傳感器,然後到陣列添加傳感器作爲提交時命名傳感器節點對象的屬性形式:

$("#form").submit(function() { 
    //deal with them; 

});