以前对调用js函数的固有理解:
<input type="button" value="选择1" onclick="depQuery1('第一个参数','第二个参数')" /> function depQuery1(field1, field2,path) { alert(field1); alert(field2); }
要调用js函数depQuery1函数,就必须要传一个给定的值,像是上面的情况,其实不是这样的...也可以这样传值
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <script> //这是一个js的函数 function depQuery(field1, field2, path) { alert(field1.value); alert(field2.value); } function depQuery1(field1, field2,path) { alert(field1); alert(field2); } </script> </HEAD> <BODY> <input type="text" id="parentDepx" name="parentDepName" value="这是默认值" /> <input type="hidden" id="pdepIdx" name="dep.pdepId" value="这是隐藏域中的id值0121021" /> <!-- 当单击下面的 选择 按钮时,会调用depQuery(pdepId,parentDep)函数 这里的pdepId是文本框的id,parentDep是隐藏域的id,会把对应的值传到depQuery函数中 --> <input type="button" value="选择" onclick="depQuery(pdepIdx,parentDepx);" /> <input type="button" value="选择1" onclick="depQuery1('第一个参数','第二个参数')" /> </BODY> </HTML>
心中的滋味只有知道...
欢迎转载,转载时请注明出处http://www.cnblogs.com/wanggd