`

js中对数组的一些处理

    博客分类:
  • js
 
阅读更多
function fOnChange(pobjThis, pstrBuyId) {                
                itemCodeSet(pstrBuyId);               
		if (eval("document.f2.SellChk_" + String(pstrBuyId)).checked == false) {
			if (fSelectCount() >= 100) {
				alert("選択が100件を超えています。" + fSelectCount() + "件");
				pobjThis.focus();
				return false;
			}
		}
		eval("document.f2.SellChk_" + String(pstrBuyId)).checked = true;
		//eval("document.f2.SellChk_" + String(pstrBuyId)).disabled = false;
		//eval("document.f2.SellChk_" + String(pstrBuyId)).style.display = "inline";
		//eval("document.f2.SellImg_" + String(pstrBuyId)).style.display = "none";

		if (pobjThis) {
			if (pobjThis.name == ("subject_code_" + pstrBuyId)) {
				if (eval("document.f2.subject_code_" + pstrBuyId).value != eval("document.f2.ck_subject_code_"
						+ pstrBuyId).value) {
					eval("document.f2.subject_code2_" + pstrBuyId).value = "";
					eval("document.f2.subject_small_id_" + pstrBuyId).value = "";
					eval("document.f2.subject_small_name_" + pstrBuyId).value = "";
					eval("document.getElementById('subject_name_" + pstrBuyId + "')").innerHTML = "";
					eval("document.f2.subject_small_name2_" + pstrBuyId).value = "";
					eval("document.getElementById('subject_name2_" + pstrBuyId + "')").innerHTML = "";
					eval("document.f2.ck_subject_code_" + pstrBuyId).value = eval("document.f2.subject_code_"
							+ pstrBuyId).value;
				}
			} else if (pobjThis.name == ("subject_code2_" + pstrBuyId)) {
				if (eval("document.f2.subject_code2_" + pstrBuyId).value != eval("document.f2.ck_subject_code2_"
						+ pstrBuyId).value) {
					eval("document.f2.subject_small_id_" + pstrBuyId).value = "";
					eval("document.f2.subject_small_name_" + pstrBuyId).value = "";
					eval("document.getElementById('subject_name_" + pstrBuyId + "')").innerHTML = "";
					eval("document.f2.subject_small_name2_" + pstrBuyId).value = "";
					eval("document.getElementById('subject_name2_" + pstrBuyId + "')").innerHTML = "";
					eval("document.f2.ck_subject_code2_" + pstrBuyId).value = eval("document.f2.subject_code2_"
							+ pstrBuyId).value;
				}
			} else if (pobjThis.name == ("subject_code_a_" + pstrBuyId)) {
				if (eval("document.f2.subject_code_a_" + pstrBuyId).value != eval("document.f2.ck_subject_code_a_"
						+ pstrBuyId).value) {
					eval("document.f2.subject_code_a2_" + pstrBuyId).value = "";
					eval("document.f2.subject_small_id_a_" + pstrBuyId).value = "";
					eval("document.f2.subject_small_name_a_" + pstrBuyId).value = "";
					eval("document.getElementById('subject_name_a_" + pstrBuyId + "')").innerHTML = "";
					eval("document.f2.subject_small_name_a2_" + pstrBuyId).value = "";
					eval("document.getElementById('subject_name_a2_" + pstrBuyId + "')").innerHTML = "";
					eval("document.f2.ck_subject_code_a_" + pstrBuyId).value = eval("document.f2.subject_code_a_"
							+ pstrBuyId).value;
				}
			} else if (pobjThis.name == ("subject_code_a2_" + pstrBuyId)) {
				if (eval("document.f2.subject_code_a2_" + pstrBuyId).value != eval("document.f2.ck_subject_code_a2_"
						+ pstrBuyId).value) {
					eval("document.f2.subject_small_id_a_" + pstrBuyId).value = "";
					eval("document.f2.subject_small_name_a_" + pstrBuyId).value = "";
					eval("document.getElementById('subject_name_a_" + pstrBuyId + "')").innerHTML = "";
					eval("document.f2.subject_small_name_a2_" + pstrBuyId).value = "";
					eval("document.getElementById('subject_name_a2_" + pstrBuyId + "')").innerHTML = "";
					eval("document.f2.ck_subject_code_a2_" + pstrBuyId).value = eval("document.f2.subject_code_a2_"
							+ pstrBuyId).value;
				}
			}
		}

		fDataSet(pstrBuyId);

		if (fDataInitialCheck(pstrBuyId)) {
			//初期内容に戻る
			fDataDelete(pstrBuyId);
		}
        if (eval("document.f2.SellChk_" + String(pstrBuyId)).checked == true) {
            $("input[name=SellChk_" + String(pstrBuyId) + "]").parents("tr:first").addClass("selected");
        } else {
            $("input[name=SellChk_" + String(pstrBuyId) + "]").parents("tr:first").removeClass("selected");
        }
		fcUpdateBotanDisp(fSelectCount());
		return true;
	}
 function fDataSet_pri(pstrBuyId) {
			var wobjNm
			var waryBuyId
			var waryShareFlg
			var waryBuyName
			var waryMembNm
			var waryPriBuyId
			var warySubCdS1
			var warySmlNmS1
			var warySubCdS2
			var warySmlNmS2
			var warySubCd2S1
			var warySmlNm2S1
			var warySubCd2S2
			var warySmlNm2S2
			var warySellChk
			var warySSmallId
			var warySSmallIdA
			var selected_Buy_id

			var wintIdx = fItemCheck(pstrBuyId);
			if (wintIdx < 0) {
				//変更保存無
				if (document.f1.csvBuyId.value.length > 0) {
					//2回目以降
					if (eval("document.f2.SellChk_" + String(pstrBuyId)).checked == true) {
						document.f1.csvBuyId.value += ",";
						document.f1.csvShareFlg.value += ",";
						document.f1.csvBuyName.value += ",";
						document.f1.csvMembNm.value += ",";
						document.f1.csvPriBuyId.value += ",";
						document.f1.csvSubCdS1.value += ",";
						document.f1.csvSmlNmS1.value += ",";
						document.f1.csvSubCdS2.value += ",";
						document.f1.csvSmlNmS2.value += ",";
						document.f1.csvSubCd2S1.value += ",";
						document.f1.csvSmlNm2S1.value += ",";
						document.f1.csvSubCd2S2.value += ",";
						document.f1.csvSmlNm2S2.value += ",";
						document.f1.csvSellChk.value += ",";
						document.f1.csvSSmallId.value += ",";
						document.f1.csvSSmallIdA.value += ",";
					}

				} else {
					document.f1.csvBuyId.value = "";
					document.f1.csvShareFlg.value = "";
					document.f1.csvBuyName.value = "";
					document.f1.csvMembNm.value = "";
					document.f1.csvPriBuyId.value = "";
					document.f1.csvSubCdS1.value = "";
					document.f1.csvSmlNmS1.value = "";
					document.f1.csvSubCdS2.value = "";
					document.f1.csvSmlNmS2.value = "";
					document.f1.csvSubCd2S1.value = "";
					document.f1.csvSmlNm2S1.value = "";
					document.f1.csvSubCd2S2.value = "";
					document.f1.csvSmlNm2S2.value = "";
					document.f1.csvSellChk.value = "";
					document.f1.csvSSmallId.value = "";
					document.f1.csvSSmallIdA.value = "";
				}
				//追加
				if (eval("document.f2.SellChk_" + String(pstrBuyId)).checked == true) {
					// チェック時,内容が元に戻った時チェックを外す。
					//if (fDataInitialCheck_pri(pstrBuyId)) {
						//document.f1.csvSellChk.value += "0";
						//eval("document.f2.SellChk_" + String(pstrBuyId)).checked = false;
						//eval("document.f2.SellChk_" + String(pstrBuyId)).disabled = true;
						//eval("document.f2.SellChk_" + String(pstrBuyId)).style.display = "none";
						//eval("document.f2.SellImg_" + String(pstrBuyId)).style.display = "inline";
					//} else {
						document.f1.csvSellChk.value += "1";
						document.f1.csvBuyId.value += pstrBuyId;
						document.f1.csvShareFlg.value += Trim(eval("document.f2.share_flg_"
								+ String(pstrBuyId)).value.replace(",", "")
								+ "");
						document.f1.csvBuyName.value += Trim(eval("buy_name_" + String(pstrBuyId)).innerHTML
								.replace(",", "")
								+ "");
						document.f1.csvMembNm.value += Trim(eval("member_name_" + String(pstrBuyId)).innerHTML
								+ "");
						document.f1.csvPriBuyId.value += Trim(eval("private_buy_id_"
								+ String(pstrBuyId)).innerHTML.replace(",", "")
								+ "");
						document.f1.csvSubCdS1.value += Trim(eval("document.getElementById('subject_code_new')").value.replace(",","") + "");
						document.f1.csvSmlNmS1.value += Trim(eval("document.getElementById('subject_name_new')").innerHTML + "");
						document.f1.csvSubCdS2.value += Trim(eval("document.getElementById('subject_code_a_new')").value.replace(",","") + "");
						document.f1.csvSmlNmS2.value += Trim(eval("document.getElementById('subject_name_a_new')").innerHTML + "");
						document.f1.csvSubCd2S1.value += Trim(eval("document.getElementById('subject_code2_new')").value.replace(",","") + "");
						document.f1.csvSmlNm2S1.value += Trim(eval("document.getElementById('subject_name2_new')").innerHTML + "");
						document.f1.csvSubCd2S2.value += Trim(eval("document.getElementById('subject_code_a2_new')").value.replace(",","") + "");
						document.f1.csvSmlNm2S2.value += Trim(eval("document.getElementById('subject_name_a2_new')").innerHTML + "");
						document.f1.csvSSmallId.value += Trim(eval("document.getElementById('subject_small_id_hi')").value + "");
						document.f1.csvSSmallIdA.value += Trim(eval("document.getElementById('subject_small_id_a_hi')").value + "");
					//}
				}
			} else {
				//変更保存有り
				if(eval("document.f2.SellChk_" + String(pstrBuyId))){

				  if (eval("document.f2.SellChk_" + String(pstrBuyId)).checked == false) {

					selected_Buy_id = document.f1.csvBuyId.value.split(",");
					waryShareFlg = document.f1.csvShareFlg.value.split(",");
					waryBuyName = document.f1.csvBuyName.value.split(",");
					waryMembNm = document.f1.csvMembNm.value.split(",");
					waryPriBuyId = document.f1.csvPriBuyId.value.split(",");
					warySubCdS1 = document.f1.csvSubCdS1.value.split(",");
					warySmlNmS1 = document.f1.csvSmlNmS1.value.split(",");
					warySubCdS2 = document.f1.csvSubCdS2.value.split(",");
					warySmlNmS2 = document.f1.csvSmlNmS2.value.split(",");
					warySubCd2S1 = document.f1.csvSubCd2S1.value.split(",");
					warySmlNm2S1 = document.f1.csvSmlNm2S1.value.split(",");
					warySubCd2S2 = document.f1.csvSubCd2S2.value.split(",");
					warySmlNm2S2 = document.f1.csvSmlNm2S2.value.split(",");
					warySellChk = document.f1.csvSellChk.value.split(",");
					warySSmallId = document.f1.csvSSmallId.value.split(",");
					warySSmallIdA = document.f1.csvSSmallIdA.value.split(",");
					//置換

					selected_Buy_id.splice(wintIdx,1);
					waryShareFlg.splice(wintIdx,1);
					waryBuyName.splice(wintIdx,1);
					waryMembNm.splice(wintIdx,1);
					waryPriBuyId.splice(wintIdx,1);
					warySubCdS1.splice(wintIdx,1);
					warySmlNmS1.splice(wintIdx,1);
					warySubCdS2.splice(wintIdx,1);
					warySmlNmS2.splice(wintIdx,1);
					warySubCd2S1.splice(wintIdx,1);
					warySmlNm2S1.splice(wintIdx,1);
					warySubCd2S2.splice(wintIdx,1);
					warySmlNm2S2.splice(wintIdx,1);
					warySSmallId.splice(wintIdx,1);
					warySSmallIdA.splice(wintIdx,1);
					warySellChk.splice(wintIdx,1);

					document.f1.csvBuyId.value = selected_Buy_id.join(",");
					document.f1.csvShareFlg.value = waryShareFlg.join(",");
					document.f1.csvBuyName.value = waryBuyName.join(",");
					document.f1.csvMembNm.value = waryMembNm.join(",");
					document.f1.csvPriBuyId.value = waryPriBuyId.join(",");
					document.f1.csvSubCdS1.value = warySubCdS1.join(",");
					document.f1.csvSmlNmS1.value = warySmlNmS1.join(",");
					document.f1.csvSubCdS2.value = warySubCdS2.join(",");
					document.f1.csvSmlNmS2.value = warySmlNmS2.join(",");
					document.f1.csvSubCd2S1.value = warySubCd2S1.join(",");
					document.f1.csvSmlNm2S1.value = warySmlNm2S1.join(",");
					document.f1.csvSubCd2S2.value = warySubCd2S2.join(",");
					document.f1.csvSmlNm2S2.value = warySmlNm2S2.join(",");
					document.f1.csvSellChk.value = warySellChk.join(",");
					document.f1.csvSSmallId.value = warySSmallId.join(",");
					document.f1.csvSSmallIdA.value = warySSmallIdA.join(",");
				}else{

					warySubCdS1 = document.f1.csvSubCdS1.value.split(",");
					warySmlNmS1 = document.f1.csvSmlNmS1.value.split(",");
					warySubCdS2 = document.f1.csvSubCdS2.value.split(",");
					warySmlNmS2 = document.f1.csvSmlNmS2.value.split(",");
					warySubCd2S1 = document.f1.csvSubCd2S1.value.split(",");
					warySmlNm2S1 = document.f1.csvSmlNm2S1.value.split(",");
					warySubCd2S2 = document.f1.csvSubCd2S2.value.split(",");
					warySmlNm2S2 = document.f1.csvSmlNm2S2.value.split(",");
					warySSmallId = document.f1.csvSSmallId.value.split(",");
					warySSmallIdA = document.f1.csvSSmallIdA.value.split(",");

					warySubCdS1[wintIdx] = Trim(eval("document.getElementById('subject_code_new')").value.replace(",","") + "");
					warySmlNmS1[wintIdx] = Trim(eval("document.getElementById('subject_name_new')").innerHTML + "");
					warySubCdS2[wintIdx] = Trim(eval("document.getElementById('subject_code_a_new')").value.replace(",","") + "");
					warySmlNmS2[wintIdx] = Trim(eval("document.getElementById('subject_name_a_new')").innerHTML + "");
					warySubCd2S1[wintIdx] = Trim(eval("document.getElementById('subject_code2_new')").value.replace(",","") + "");
					warySmlNm2S1[wintIdx] = Trim(eval("document.getElementById('subject_name2_new')").innerHTML + "");
					warySubCd2S2[wintIdx] = Trim(eval("document.getElementById('subject_code_a2_new')").value.replace(",","") + "");
					warySmlNm2S2[wintIdx] = Trim(eval("document.getElementById('subject_name_a2_new')").innerHTML + "");
					warySSmallId[wintIdx] = Trim(eval("document.getElementById('subject_small_id_hi')").value + "");
					warySSmallIdA[wintIdx] = Trim(eval("document.getElementById('subject_small_id_a_hi')").value + "");

					document.f1.csvSubCdS1.value = warySubCdS1.join(",");
					document.f1.csvSmlNmS1.value = warySmlNmS1.join(",");
					document.f1.csvSubCdS2.value = warySubCdS2.join(",");
					document.f1.csvSmlNmS2.value = warySmlNmS2.join(",");
					document.f1.csvSubCd2S1.value = warySubCd2S1.join(",");
					document.f1.csvSmlNm2S1.value = warySmlNm2S1.join(",");
					document.f1.csvSubCd2S2.value = warySubCd2S2.join(",");
					document.f1.csvSmlNm2S2.value = warySmlNm2S2.join(",");
					document.f1.csvSSmallId.value = warySSmallId.join(",");
					document.f1.csvSSmallIdA.value = warySSmallIdA.join(",");

				}
			  }
			}
		}

 

分享到:
评论

相关推荐

    Javascript中二维数组的遍历

    在 Javascript 中,二维数组的遍历是一种非常常见的操作。二维数组,即多维数组的特殊情况,是指每个元素也是一个数组的数组。这种数据结构在实际应用中非常常见,例如,在表单处理、数据分析等领域。今天,我们将...

    js数组相减简单示例【删除a数组所有与b数组相同元素】

    扩展阅读中提及的专题,例如《JavaScript数组操作技巧总结》、《JavaScript遍历算法与技巧总结》等,为读者提供了更多的学习资源。通过这些资源,读者可以更加全面地掌握JavaScript中数组操作的多种技巧和方法,从而...

    js对ajax返回数组的处理介绍

    在处理AJAX返回的数据时,如果数据是数组形式,我们通常需要进行一些处理步骤来确保能够正确地解析和使用这些数据。 在上述例子中,我们看到一个使用PHP实现的`ajaxcheckedlessonsAction`函数,该函数用于通过DAO...

    javascript中数组、对象

    在JavaScript中,数组和对象是两种非常基础且重要的数据结构,它们被广泛应用于各种场景,如数据存储、逻辑处理和对象表示。这篇文章将深入探讨这两种数据类型,以及相关的操作和工具。 **一、数组** 数组在...

    javascript中的数组对象以及json学习笔记

    在JavaScript中,数组对象和JSON(JavaScript Object Notation)是两种非常重要的数据结构,它们在处理和存储数据方面起着核心作用。这篇学习笔记将深入探讨这两种数据结构的特性和用法。 首先,我们来了解...

    js中数组中相同的元素进行整合并创建一个新数组.pdf

    在JavaScript编程中,数组操作是常见的任务之一,特别是在处理数据集合时。本示例中,我们探讨的是如何处理包含重复元素的数组,并将其整合成一个新的结构。这个问题可以通过一个名为`sortArr`的函数来解决,它接收...

    collectjs是一个用于在JavaScript中处理数组和对象库

    总的来说,`collect.js` 是JavaScript开发中处理数组和对象的强大工具,无论是在前端还是后端,都能提供高效的数据处理能力。通过利用其丰富的API,开发者可以更轻松地处理复杂的数据操作,同时保持代码的简洁和可...

    js判断数组是否相等的方法

    在JavaScript中,判断两个数组是否相等是一个常见的需求,尤其在处理数据比较或者验证时。根据标题和描述,我们可以区分两种不同的场景: 1. **数组完全相等**:在这种情况下,不仅要求数组中的元素相同,而且元素...

    js数组说明大全

    数组的使用非常广泛,以下是对 JavaScript 数组的详细说明。 一、创建数组 JavaScript 中可以使用多种方式创建数组,例如: * 使用 new Array() 构造函数创建数组:var a = new Array("cctv","sxtv","tytv"); * ...

    求js两个数组的差集,以便测试

    #### 一、JavaScript数组与操作 **数组定义:** 在JavaScript中,数组是一种用于存储多个值的数据结构。数组中的每个元素都有一个对应的索引(从0开始),并且可以通过该索引访问数组中的元素。 示例代码: ```...

    全国城市js数组

    在实际实现过程中,开发者可能会创建两个JavaScript数组,一个存储省份信息,另一个存储城市信息。例如: ```javascript var provinces = [ {name: '北京市', cities: ['东城区', '西城区', '朝阳区', ...]}, {...

    js实现json数组分组合并操作示例

    这是JavaScript中处理数组的基本方法。`for`循环的语法为: ```javascript for (var i = 0; i ; i++) { // 循环体 } ``` 这里,`i`是索引,`array.length`表示数组的长度。 2. **对象属性的访问和赋值**: ...

    javaScript Array数组分页处理

    javaScript:将Array数组分页处理,支持分页数据容错; js文件:Page4array分页处理工具类; 兼容版本ES6。 博文:https://blog.csdn.net/HTouying/article/details/88898258

    JavaScript如何获取数组最大值和最小值

    在JavaScript中,获取数组的最大值和最小值是常见的操作,特别是在数据分析、数据处理或界面动态更新等场景。这里我们将详细探讨如何使用JavaScript实现这个功能。 首先,我们可以使用内置的Math对象中的`Math.max...

    JavaScript获取多个数组的交集

    同时,理解这些基本操作也有助于我们更好地掌握JavaScript数组处理的技巧。在阅读类似《JavaScript高级程序设计》这样的书籍,或者在iteye这样的技术社区中,你可以找到更多关于数组操作和算法优化的知识,不断提升...

    JavaScript 对象与数组参考大全

     本文列举了各种JavaScript对象与数组,同时包括对上述每一对象或数组所完成工作的简短描述,以及与其相关的属性方法,以及事件处理程序,还注明了该对象或数组的父对象用户同样可能需要参考Online Companion中的超级...

    js获取对象,数组所有属性键值(key)和对应值(value)的方法示例

    尽管数组在概念上与对象不同,但在JavaScript中,数组也被视为一种特殊的对象,其索引被视为属性。 1. 获取对象的键(keys)和值(values) 在JavaScript中,我们可以使用`for...in`循环遍历对象的所有可枚举属性...

    JavaScript jQuery 中定义数组与操作及jquery数组操作

    JavaScript 和 jQuery 中的数组操作是编程中非常基础且重要的部分,尤其在处理数据集合时。在 JavaScript 中,数组是一种特殊的数据结构,可以存储各种类型的数据,包括整型、字符串、对象等。虽然 JavaScript 不...

    js读取本地文件到字节数组

    3. **处理字节数组**:最后,可以遍历 Uint8Array 对象,并将其转换为普通的 JavaScript 数组。这一步虽然不是必须的,但在某些情况下可能更方便进行后续处理。 #### 总结 使用 JavaScript 读取本地文件并转换为...

    js数组的深拷贝

    在JavaScript中,数组的深拷贝是一个常见的需求,它涉及到数据结构的复制,尤其是在处理复杂对象和嵌套数据时。深拷贝与浅拷贝不同,浅拷贝只是复制引用,而深拷贝会创建一个新的对象,包含原始数组的所有元素,并...

Global site tag (gtag.js) - Google Analytics