我需要将以下行转换为 JavaScript:
cOrderNumList = frmSearch.OrderNumList.Value
cOrderNumList = Replace(cOrderNumList, Chr(10), "")
aOrderNumList = Split(cOrderNumList,",")
什么是 JavaScript 等价物Chr(10)
我需要将以下行转换为 JavaScript:
cOrderNumList = frmSearch.OrderNumList.Value
cOrderNumList = Replace(cOrderNumList, Chr(10), "")
aOrderNumList = Split(cOrderNumList,",")
什么是 JavaScript 等价物Chr(10)
cOrderNumList = frmSearch.OrderNumList.Value;
cOrderNumList = cOrderNumList.replace(String.fromCharCode(10), "");
aOrderNumList = cOrderNumList.split(",");
我的更改是否正确?
cOrderNumList = Replace(cOrderNumList, String.fromCharCode(10), "")
要将字符代码转换为字符串,您可以执行以下操作:
var outputString = yourString.replace(cOrderNumList, String.fromCharCode(10))
您会注意到,这会将 char 代码转换为一个字母的字符串。您不能真正转换为纯 char,因为 JavaScript 中不存在 char 类型。
您可以使用String.fromCharCode但如果您的角色是硬编码的,最好是简单地使用"\n"
.
由于替换只会替换第一个,我建议使用这个简单的正则表达式:
cOrderNumList = cOrderNumList.replace(/\n/g, "")