전달되는 인자값을 일일이 선언해주는 대신
Javascript 를 이용하여 전달
* 기존방법
var dataHd = ""; dataHd = dataHd + "hd_start_dt:STRING,"; dataHd = dataHd + "hd_end_dt;STRING";
ds_cdtn = NameValue(ds_cdtn.RowPosition, "hd_start_dt") = value; ds_cdtn = NameValue(ds_cdtn.RowPosition, "hd_end_dt") = value; |
이 방법은 조회부가 수정되면 Header 와 값을 수정해줘야 하는 불편함이 있어
이 부분을 Javascript 로 공통함수를 제작
var srchData = new Array(); function makeSearchDataSet(logFlg) { var searchElSize = parseInt(($('input[name^=s_], select[name^=s_], radio[name^=s_], check[name^=s_], textarea[name^=s_]').size()),10); var dataHeader = ''; var loopCount = 1; var logData = ''; srchData = new Array(); if(searchElSize > 0) { $('input[name^=s_], select[name^=s_], radio[name^=s_], check[name^=s_], textarea[name^=s_]').each(function() { if(this.type == 'radio') { if($(this).is(':checked')) { dataHeader += ToUpper($(this).attr('name'))+','; } } else if(this.type == 'checkbox') { if(dataHeader.indexOf(ToUpper($(this).attr('name'))) == -1) { dataHeader += ToUpper($(this).attr('name'))+','; } } else { dataHeader += ToUpper($(this).attr('name'))+','; } }); dataHeader = dataHeader.substr(0,dataHeader.lastIndexOf(',')); logData += 'DATAHEADER : '+ dataHeader +'\n'; ds_cdtn.SetDataHeader(dataHeader); ds_cdtn.AddRow(); var checkBoxList = ''; $('input[name^=s_], select[name^=s_], radio[name^=s_], check[name^=s_], textarea[name^=s_]').each(function() { var targetValue =''; if(this.type == 'radio') { if($(this).is(':checked')) { targetValue = $(this).val(); ds_cdtn.NameValue(1, $(this).attr('name')) = targetValue; logData += $(this).attr('name')+':'+targetValue+'\n'; if (!isNull(targetValue)) { srchData.push($(this).attr('alt')+':'+targetValue); } } } else if(this.type == 'checkbox') { if(checkBoxList.indexOf($(this).attr('name')) == -1) { checkBoxList = $(this).attr('name')+','; var tempStr = ''; $('input[name='+$(this).attr('name')+']').each(function(){ if($(this).is(':checked')) { tempStr += $(this).val()+','; } }); targetValue = tempStr; targetValue = targetValue.substr(0,targetValue.lastIndexOf(',')); ds_cdtn.NameValue(1, $(this).attr('name')) = targetValue; logData += $(this).attr('name')+':'+targetValue+'\n'; if (!isNull(targetValue)) { srchData.push($(this).attr('alt')+':'+targetValue); } } } else { targetValue = $(this).val(); ds_cdtn.NameValue(1, $(this).attr('name')) = targetValue; logData += $(this).attr('name')+':'+targetValue+'\n'; if (this.type != "hidden" && !isNull(targetValue)) { if (this.type == 'select-one') { srchData.push($(this).attr('alt')+':'+$(this).children("option:selected").text()); } else { srchData.push($(this).attr('alt')+':'+targetValue); } } } }); } } |
적용예시
<head> <script language="javascript"> function btnSearch() { makeSearchDataSet(); tr_list.KeyValue = 'JSP(I:DS_CDTN=ds_cdtn,O:DS_RSLT=ds_list)'; tr_list.Action = '/pm/pm02/pm02_02010101_list01.do'; tr_list.Post(); } </script>
<!--------------------------------------------- DataSet Component S ------------------------------------------------> <object id="tr_list" classid="<%=GauceId.TR%>" > <param name="KeyName" value="Toinb_dataid4"/> <param name="Parameters"value="gauceDataset=true"/> </object> <object id="ds_list" classid="<%=GauceId.DATASET%>"></object> <object id="ds_cdtn" classid="<%=GauceId.DATASET%>"></object> <!--------------------------------------------- DataSet Component E ------------------------------------------------> </head>
<object id="gr_list" classid="<%=GauceId.GRID%>" width="100%" height="410" style="font-family:굴림; font-size:9pt;z-index:1;"> <param name="DataID" value="ds_list"/> <param Name="BorderStyle" value="1"> <param name="format" value=' <FC>id=no, name=No, value={String(currow)}, width=45, <%=center%> </FC> ... ... '/> </object>
|