我用js动态创建一些表单元素,代码如下:<div id="FileList">
<p>
<label>项目名称:</label>
<input type="hidden" name="orgLookup.id" value="${orgLookup.id}"/>
<input type="text" class="" name="dwz_orgLookup.orgName" value="" readonly="readonly"/>
<a class="btnLook" href="<%=Url.Action("UserOrgLookup", "Admin")%>" lookupGroup="" lookupName="orgLookup" maxable="false" resizable="false"><hi:text key="查找带回"/></a>
<a href="javascript:;" onclick="AddFile();">[+]</a>
</p>
</div>var index = 1;
function AddFile() {
var ul = document.getElementById("FileList");
var inputDiv = document.createElement("p");
//inputDiv.setAttribute("Id", "P" + index);
var leabl = document.createElement("label");
leabl.innerHTML = "项目名称:";
var file = document.createElement("input");
file.setAttribute("type", "text");
file.setAttribute("class", "textInput required");
file.setAttribute("readonly", "readonly");
file.setAttribute("id", "dwz_orgLookup" + index+".orgName");
file.setAttribute("name", "dwz_orgLookup" + index+".orgName");
var select = document.createElement("a");
select.setAttribute("class", "btnLook");
select.setAttribute("href", "<%=Url.Action("UserOrgLookup", "Admin")%>");
select.setAttribute("lookupGroup", "");
select.setAttribute("lookupName", "orgLookup" + index);
select.setAttribute("maxable", "false");
select.setAttribute("resizable", "false");
select.innerHTML = "<hi:text key=\"查找带回\"/>";
var btnDel = document.createElement("a");
btnDel.setAttribute("href", "javascript:;");
btnDel.innerHTML = "[-]";
btnDel.setAttribute("Id", index);
btnDel.onclick = function () {
inputDiv.removeChild(file);
inputDiv.removeChild(btnDel);
ul.removeChild(inputDiv);
}
inputDiv.appendChild(leabl);
inputDiv.appendChild(file);
inputDiv.appendChild(select);
inputDiv.appendChild(btnDel);
ul.appendChild(inputDiv);
index++;
}创建成功后的表单元素,点击查找带回,结果不跳窗了...郁闷了...也就是说完全读不到外部JS了,CSS倒是能读到...
<p>
<label>项目名称:</label>
<input type="hidden" name="orgLookup.id" value="${orgLookup.id}"/>
<input type="text" class="" name="dwz_orgLookup.orgName" value="" readonly="readonly"/>
<a class="btnLook" href="<%=Url.Action("UserOrgLookup", "Admin")%>" lookupGroup="" lookupName="orgLookup" maxable="false" resizable="false"><hi:text key="查找带回"/></a>
<a href="javascript:;" onclick="AddFile();">[+]</a>
</p>
</div>var index = 1;
function AddFile() {
var ul = document.getElementById("FileList");
var inputDiv = document.createElement("p");
//inputDiv.setAttribute("Id", "P" + index);
var leabl = document.createElement("label");
leabl.innerHTML = "项目名称:";
var file = document.createElement("input");
file.setAttribute("type", "text");
file.setAttribute("class", "textInput required");
file.setAttribute("readonly", "readonly");
file.setAttribute("id", "dwz_orgLookup" + index+".orgName");
file.setAttribute("name", "dwz_orgLookup" + index+".orgName");
var select = document.createElement("a");
select.setAttribute("class", "btnLook");
select.setAttribute("href", "<%=Url.Action("UserOrgLookup", "Admin")%>");
select.setAttribute("lookupGroup", "");
select.setAttribute("lookupName", "orgLookup" + index);
select.setAttribute("maxable", "false");
select.setAttribute("resizable", "false");
select.innerHTML = "<hi:text key=\"查找带回\"/>";
var btnDel = document.createElement("a");
btnDel.setAttribute("href", "javascript:;");
btnDel.innerHTML = "[-]";
btnDel.setAttribute("Id", index);
btnDel.onclick = function () {
inputDiv.removeChild(file);
inputDiv.removeChild(btnDel);
ul.removeChild(inputDiv);
}
inputDiv.appendChild(leabl);
inputDiv.appendChild(file);
inputDiv.appendChild(select);
inputDiv.appendChild(btnDel);
ul.appendChild(inputDiv);
index++;
}创建成功后的表单元素,点击查找带回,结果不跳窗了...郁闷了...也就是说完全读不到外部JS了,CSS倒是能读到...
select.setAttribute("href", '<%=Url.Action("UserOrgLookup", "Admin")%>');
试下
$(inputDiv).initUI();