JS 动态显示 获取下拉框的多个值

时间:2023-03-08 18:41:17
JS 动态显示 获取下拉框的多个值
 <script type="text/javascript">
function GetProcessVal(i, t) {
document.getElementsByName("items[#index#].typeName")[i].value += t.value + ',';
}
</script>

后台代码:

 
static StringBuilder sbProcessingtype = null;

private void getProcessingtype()
        {
           if (null == sbProcessingtype)
            {
                sbProcessingtype= new StringBuilder();
               string str_Query = "select comoboxText  from  Bs_ComboBoxConfig  where comoboxID='15' order by comoboxValue asc";
                IList<string> list = objComboBoxConfigRepository.ExecuteSQLReturnStr(str_Query);

sbProcessingtype.Append("<select  onchange=\"GetProcessVal({0},this)\"   name=\"items[#index#].Processingtype\"  > <option value=\"\"></option>");
               int count = list.Count;
               for (int i = ; i < count; i++)
                {
                    sbProcessingtype.Append("<option value=\"" + list[i] + "\">" + list[i] + "</option>");
                }
            }
        }

调用 :

 private string BindTable(IList<VOutProceManager> objList, bool isDeleted)
{
sbProcessingtype = null;
getProcessingtype();//调用方法
string strCalMethod = "";
StringBuilder sb = new StringBuilder();
int i = ;
string currentdate = DateTime.Now.ToString("yyyy-MM-dd");
string PriceType = Convert.ToString(base.GetComboBoxConfig());
foreach (VOutProceManager obj in objList)
{
sb.Append("<tr class=\"unitBox\">");
if (isDeleted)
sb.Append("<td style='width:30px' ><a class='btnDel' style='width:22px' target=\"ajaxTodo\" style=\"cursor:pointer\" href=\"outProcessGL/OProcessRequisition/DelMaterialInfo?id=" + obj.Id + "&iscoper=" + obj.Isbom + "\" >删除</a></td>");
else
sb.Append("");
sb.Append("<input type=\"hidden\" name=\"items[#index#].Id\" submitName=\"items[" + i + "].Id\" value=\"" + obj.Id + "\" /> ");
sb.Append("<input type=\"hidden\" name=\"items[#index#].bomID\" submitName=\"items[" + i + "].bomID\" value=\"" + obj.bomID + "\" /> ");
sb.Append("<input type=\"hidden\" name=\"items[#index#].Isbom\" submitName=\"items[" + i + "].Isbom\" value=\"" + obj.Isbom + "\" /> ");
sb.Append("<td ><input class=\"textInput \" size='15' readonly=\"readonly\" value=\"" + obj.mouldNo + "\" > </td>");
sb.Append("<td ><input class=\"textInput \" size='9' readonly=\"readonly\" name=\"items[#index#].partName\" submitName=\"items[" + i + "].partName\" value=\"" + obj.partName + "\" > </td>");
sb.Append("<td ><input class=\"textInput \" size='3' readonly=\"readonly\" name=\"items[#index#].drawingNo\" submitName=\"items[" + i + "].drawingNo\" value=\"" + obj.drawingNo + "\" > </td>");
sb.Append("<td ><input class=\"textInput required number\" size='9' name=\"items[#index#].qty\" submitName=\"items[" + i + "].qty\" value=\"" + obj.qty + "\" > </td>");
sb.Append("<td ><input class=\" textInput \" size='15' name=\"items[#index#].typeName\" submitName=\"items[" + i + "].typeName\" value=\"" + obj.typeName + "\" > ");
sb.Append(string.Format(sbProcessingtype.ToString(), i) + " </td>");//调用sbProessingType
sb.Append("</tr>");
i++;
}
return sb.ToString();
}