首页 > 代码库 > 动态生成JS
动态生成JS
private void GenerateDrugAndProdJavaScript() { StringBuilder script = new StringBuilder(); script.Append("<script type=text/javascript>"); script.Append("function selectDrugAndProd(){"); script.Append("var drug = document.getElementById(‘" + hdnDrug.ClientID + "‘).value;"); script.Append("var productList = document.getElementById(‘" + hdnProduct.ClientID + "‘).value;"); script.Append("result = showModalDialogDisplay(‘../Dialog/DrugProdSelect.aspx?" + ConstValue.QUERY_STRING_KEY_SELECTED_DRUG_CODE + "=‘ + drug + ‘" + "&" + ConstValue.QUERY_STRING_KEY_SELECTED_PRODUCT_CODES + "=‘ + productList" + ", null, 650, 400);"); script.Append("if(result != null && typeof(result) == ‘object‘) {"); script.Append("document.getElementById(‘" + hdnDrug.ClientID + "‘).value = http://www.mamicode.com/result[0];"); script.Append("document.getElementById(‘" + txtDrug.ClientID + "‘).value = http://www.mamicode.com/result[1];"); script.Append("document.getElementById(‘" + hdnDrugName.ClientID + "‘).value = http://www.mamicode.com/result[1];"); script.Append("document.getElementById(‘" + hdnProduct.ClientID + "‘).value = http://www.mamicode.com/result[3];"); script.Append("document.getElementById(‘" + txtProduct.ClientID + "‘).value = http://www.mamicode.com/result[4];"); script.Append("document.getElementById(‘" + hdnProductName.ClientID + "‘).value = http://www.mamicode.com/result[4];"); script.Append("}"); script.Append("}"); script.Append("</script>"); Page.ClientScript.RegisterClientScriptBlock(typeof(string), "DrugAndProdJavaScript", script.ToString()); }
动态生成JS
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。