Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 11th, 2003, 03:47 AM
Authorized User
 
Join Date: Sep 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default form options value SQL

how do i put an sql statement inside if-else statement?? or is that possible?
my aim is to check if the listbox is not selected(options!=0) then I will add sql statement ("AND table.field=value")

my code:
<%
sql = "SELECT * FROM ..WHERE table.field ='"& value & "'"

if (document.formname.listboxname.options[0].value!=0)
    sqlsort = "AND table1.field1 ='"& value1 & "'"
end if
%>
 
Old September 24th, 2003, 02:04 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Assuming that the code is not on the page that the form is on, but rather on another page that the form submits to, you can try this. Let me know if it's what you're looking for.

<%
    ListBox = request("ListBox")

    set rs = server.createobject("adodb.recordset")
    sql = "select * from table"
    sql = sql & " where field1 = '" & Value1 & "'"
    if ListBox = "" then
        sql = sql & " and field2 = '" & Value2 & "'"
    end if
    rs.open sql, db, 3, 3
%>






Similar Threads
Thread Thread Starter Forum Replies Last Post
IE 7 form select options harpua HTML Code Clinic 0 May 9th, 2007 11:59 PM
Submit options edove Infopath 1 May 2nd, 2007 09:05 AM
startup options mjuliao Access 4 November 22nd, 2005 04:45 PM
document form options value sql bubblez Classic ASP Databases 25 October 2nd, 2003 01:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.