我正在使用 javascript 设置两个标签的值。当我设置两个标签的文本时,我的代码工作正常。但是,我想在单击按钮时使用标签文本,但我无法获取标签的值。
我的javascript是这样的:
<script type="text/javascript" language="javascript">
function getIndex(index, x,fid) {
// alert('You have Selected Flight Number:' + index);
if (x == "a") {
document.getElementById('lblAmount').innerHTML = index;
document.getElementById('lblFlight1').innerHTML = fid;
}
if (x == "b") {
document.getElementById('lblAmount1').innerHTML = index;
document.getElementById('lblFlight2').innerHTML = fid;
}
var am1, am2, amount;
am1 = document.getElementById('lblAmount').innerHTML;
am2 = document.getElementById('lblAmount1').innerHTML;
amount = parseFloat(am1) + parseFloat(am2);
document.getElementById('Amount').innerHTML = amount.toString();
}
</script>
我的两个标签是:
<asp:Label ID="lblFlight1" runat="server" Text=""></asp:Label>
<asp:Label ID="lblFlight2" runat="server" Text=""></asp:Label
我获取标签值的代码:
Dim f1 As String = lblFlight1.Text
Dim f2 As String = lblFlight2.Text
Response.Redirect("AirPrice.aspx?Flight1=" & f1 & "&Flight2=" & f2)