无法在ASP中获取隐藏字段值

时间:2016-04-07 13:08:09

标签: javascript asp-classic

我的asp文件中有一个隐藏字段,我使用JavaScript函数为隐藏字段赋值。但是,我无法获得价值。

我必须获取隐藏的字段值并传递给查询。

我的JS代码:

Do Until RS.EOF%>
<tr>
    <td valign="middle" align="center" class="style1">
        <input  type="checkbox" name="CompanyID_Merge" value="<%=RS("CompanyID")%>" onchange="checkboxlimit();" />
    </td>
    <td valign="middle" align="center"  class="style1">
        <a href="/main/league_info/companies/company_info.asp?CompanyID=<%=RS("CompanyID")%>"target="_blank"><%=RS("CompanyName")%></a>
    </td>
</tr>
<%               
    RS.MoveNext
Loop
%>
</table>
<%
End If
RS.Close
SET RS = Nothing
Conn.Close
%>
<input id="Hidden1" type="hidden" name="CompanyID_hidden" runat="server" value=""/> 
<% 
    CompanyID_Merge=Request.Form("CompanyID_hidden")
    Response.Write("chk" & Request.Form("CompanyID_hidden"))
    Conn.Open strConn
    SQL = "SELECT"
    SQL = SQL & " Projects.CompanyID, Projects.ProjectID, Projects.ProjectName, Projects.SeasonYear, Seasons.Season, Activities.ActivityName,"
    SQL = SQL & " FROM Projects"
    SQL = SQL & " AND ProjectAssociations.RenewedProjectID = " & CheckNumber(ProjectID)
    SQL = SQL & " WHERE Projects.CompanyID = " & CheckNumber(CompanyID_Merge)

HTML和ASP:

    ProgressBar.ProgressBarStyle style = new ProgressBar.ProgressBarStyle();
    style.background = new TextureRegionDrawable(new TextureRegion(new Texture("loadingFrame.png")));
    style.background.setMinHeight((float) (HEIGHT*0.1));
    style.knob = new TextureRegionDrawable(new TextureRegion(new Texture("loading.png")));
    style.knob.setMinHeight((float) (HEIGHT * 0.06));
    style.knobBefore = style.knob;
    //style.knob.setMinWidth((float) (WIDTH * 0.6));

    bar = new ProgressBar(0, 100, 1, false, style);
    bar.setAnimateDuration(1);
    bar.setValue(50);

    bar.setBounds(cam.position.x - (float) (WIDTH * 0.3), (float) (cam.position.y + HEIGHT * 0.38), (float) (WIDTH * 0.6), (float) (HEIGHT * 0.1));

1 个答案:

答案 0 :(得分:0)

只有在提交表单或使用AJAX后,您才能获得服务器端的值。

也就是说,您不需要将复选框值分配给隐藏字段,您可以使用以下名称获取经典ASP中所有选中复选框的值:

<%
    Response.Write("selected " & Request.Form("CompanyID_Merge").Count & " items<br />")
    For x=1 To Request.Form("CompanyID_Merge").Count
        Response.Write(Request.Form("CompanyID_Merge").Item(x) & "<br />")
    Next
%>