Java脚本返回错误值

Java script return false value

本文关键字:错误 返回 脚本 Java      更新时间:2024-01-11

当我尝试使用c#i运行javascript时,得到的值是001-3undefined,而不是001-3

这是我的c#代码

SalesReturn = "javascript:returnSale('&itemcode=" & dr_shop(0) & "&csid=" & csid & "')"

javascript

function returnSale(itemcode, csid) { mwindow = window.open("SaleReturnDetail.aspx?" + itemcode + csid , "SalesReturn", "height=225,width=800,status=yes,toolbar=no,menubar=no") mwindow.moveTo(100, 150); }

使用request.querystring 获取值

itemcode = Request.QueryString("itemcode") csid = Request.QueryString("csid")

我得到了itemcode的真实值,但错误的csid值

将值作为单个值传递给函数returnSale,因此只传递项代码。

尝试将其更改为returnSale('&itemcode=" & dr_shop(0) & "','&csid=" & csid & "')"

为了可读性,您可以将函数更改为;

SalesReturn = "javascript:returnSale('" & dr_shop(0) & "','" & csid & "')"
function returnSale(itemcode, csid) { 
    var mwindow;
    mwindow = window.open("SaleReturnDetail.aspx?itemcode=" + itemcode + "&csid=" + csid , "SalesReturn", "height=225,width=800,status=yes,toolbar=no,menubar=no"); 
    mwindow.moveTo(100, 150); 
}