在我的Script.js
我試圖推動對象array =>對象數組。將對象推到js或jquery中的數組?
$("#save_filter").click(function(){
var filter_saved = new Object();//Create new object to store the filter have been saved.
var customer_type_selected = $('#id_customer_type :selected').text();
var list_tag_selected = $("#tag_checked").val();
var filter_name = $("#put_filter_name").val();
// Save filter name to the object={tag:[2,3,], customer_type:'TDO', more...}
filter_saved = {
customer_type: customer_type_selected,
tag: list_tag_selected
};
var array_obj_filter_saved = []
//I am trying...
array_obj_filter_saved.push(filter_saved);//push every objects to array
alert(array_obj_filter_saved.length);
});
我的陣列會是這樣assciated陣列
array_obj_filter_saved = {"time1":filter_saved1,"time2":filter_saved2}
任何人都知道我可以每個對象推到一個數組或關聯數組?
*** filter_saved此對象將創建在形式選擇每次基地(customer_type_selected(choicefield),list_tag_selected(checkboxs))
對不起,我不清楚競猜:我想是array_obj_filter_saved.push(filter_saved); //推每個對象數組 所以我的array_obj_filter_saved = [object_saved1,object_saved2,...] Thx。 – kn3l 2009-12-24 11:24:18