p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Basics (http://p2p.wrox.com/forumdisplay.php?f=61)
-   -   how to pass checkbox selected value to Query (http://p2p.wrox.com/showthread.php?t=98783)

Amuthapriya April 7th, 2016 02:44 AM

how to pass checkbox selected value to Query
 
Hi,

my code details is below
----
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">
-- </td>
</tr>
<%
RS.MoveNext
Loop
%>
</table>
<%


End If
RS.Close
SET RS = Nothing
Conn.Close
%>

<%
CompanyID_Merge=Request.Form("CompanyID_Merge")
Conn.Open strConn
SQL = "SELECT"
SQL = SQL & " Projects.CompanyID, Projects.ProjectID, Projects.ProjectName, Projects.SeasonYear, Seasons.Season, Activities.ActivityName,"
------------------ SQL = SQL & " WHERE Projects.CompanyID = " & CheckNumber(CompanyID_Merge)
SET RS = Conn.Execute(SQL)

I am getting CompnayID_Merge value is null only. I need to pass that checkbox value to above query. I am struggling from past one week.
can somebody please find out what I did wrong?

mat41 April 10th, 2016 09:55 PM

Where is your form? You need to post a form to the page to all this to work:

CompanyID_Merge=Request.Form("CompanyID_Merge")

without a form this can not work. You need a form tag, submit button. Then move your ASP to the top of the page and check of the form collection has a value e.g:

Code:

<%
if trim(Request.Form("CompanyID_Merge")) <> "" then
        CompanyID_Merge=Request.Form("CompanyID_Merge")
        Conn.Open strConn
        SQL  = "SELECT Projects.CompanyID, Projects.ProjectID, Projects.ProjectName, Projects.SeasonYear, Seasons.Season, " & _
        "Activities.ActivityName WHERE Projects.CompanyID = " & CheckNumber(CompanyID_Merge) & ";"
    SET RS = Conn.Execute(SQL)
else
  response.write "There is nothing in the form collection to process...."
end if
%>



All times are GMT -4. The time now is 05:38 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.