顯示具有 ASP 標籤的文章。 顯示所有文章
顯示具有 ASP 標籤的文章。 顯示所有文章

2015年8月12日 星期三

[ASP] ASP/JS互相傳值

參考來源

test.asp
<script language="javascript">
  var emp_id = "<%= catchID %">"; //asp傳值給js ,其實只有這一行 
  document.form1.method = "post";
  document.form1.action = "person.asp?emp_no=" + encodeURIComponent(emp_id);
  //js把參數傳回給asp,說穿了也只是帶參數傳回而已,就上面那一行而已
  //encodeURIComponent是安全考量加的(避免類似XSS攻擊)
  //如果要回傳多參數, 再用&連接
  document.form1.submit();
</script>

[ASP] 接GET/POST值

ASP接HTML(GET)

test.html
<html>
  <form action="test.asp" method="get">
    <input name="tid" type="text" />
    <input type="submit" />
  </form>
</html>

test.asp
<%
response.write encodeURIComponent(request("tid"))
%>

ASP接HTML(POST)
把上面例子http method的get改成post即可
  <form action="test.asp" method="post">