这些是用JavaScript编写的函数的两个相关行:
var v_depttime = document.getElementById("EDDepttime").value ;
url = url+"?select_bno="+v_busno+"&select_depttime="+v_depttime ;
它将select_depttime
作为2010-01-24 14:30:00
发送
我希望它是一个URL编码的字符串,如2010-01-24%2014:30:00
如何在JavaScript中完成?
答案 0 :(得分:9)
答案 1 :(得分:3)
使用encodeURIComponent:
url = url +
"?select_bno=" + encodeURIComponent(v_busno) +
"&select_depttime=" + encodeURIComponent(v_depttime);