我的if
陈述有问题,else
并且else if
。
这是我的代码:
function draw(d) {
var testarray = JSON.parse(a);
var testarray1 = JSON.parse(a1);
var testarray2 = JSON.parse(a2);
var Yaxis = $("#<%=hidden10.ClientID%>").val();
if (d == 1)
{
var c = testarray
Yaxis = 'data';
}
else if (d == 1)
{
var e = testarray1
Yaxis = 'data1';
}
else if (d == 2)
{
var c = testarray
Yaxis = 'data2';
}
else if (d == 2)
{
var e = testarray1
Yaxis = 'data3';
}
else(d == 3)
{
var e = testarray1
Yaxis = 'data4';
}
当我调试代码时,它只会点击d==1
然后转到d==3
并跳过1
and 2
。因为yaxis
它只显示data4
,不显示data
,data1
和data2
在我的图表上。
显然我的else
陈述不正确,但我已经用谷歌搜索了该if
陈述,似乎我做得正确,但它不起作用。
d
是从 vb 后面的代码调用的单选按钮:
Select Case RadioButtonList1.SelectedItem.Value
Case 1
Dim Yaxis As String
If RadioButtonList1.SelectedItem.Value = 1 Then
Yaxis = "data"
End If
hidden10.Value = Yaxis
For Each row In Year1
testarray.Add(row("kWh"))
Next row
Dim arrayJsonTest1 As String = serializer1.Serialize(testarray)
Dim arrayJson11 As String = serializer1.Serialize(testarray1)
hidden.Value = arrayJsonTest1
hidden1.Value = arrayJson11
hidden2.Value = arrayJson12
ScriptManager.RegisterStartupScript(Me.Page, Me.GetType, "draw", "javascript:draw(1);", True)