Selecting specific values - ASP

  • Hi,

    I am pulling off records from a database using a search in a form field. The search part and retrieval part works okay, but now I am a little baffled at how to allow a user to select a record and send the details of this record to another page for processing...

    Does anyone have any ideas?

    Thanks

  • I'm not an ASP Guru, but do you mean something like this?

    
    
    <!-- #include file="top.asp" -->

    <html>
    <%WriteHeader("Mailinglisten")%>
    <body>
    <%WriteHome

    CatchVisitor()

    %>

    <form action="mailinglist.asp" name="Mailinglist">
    <table>
    <tr>
    <td>
    <font class="frank">Mailing Liste</font>
    </td>
    <td>
    <select size="1" style="width:175px;" name="Liste">
    <option value="ASP">ASP</option>
    <option value="Database Journal">Database Journal</option>
    <option value="DB Diverse">DB Diverse</option>
    <option value="DB/2">DB/2</option>
    <option value="ITtoolbox">ITtoolbox</option>
    <option value="KnowledgeBase">KnowledgeBase</option>
    <option value="MaxDB">MaxDB</option>
    <option value="MySQL">MySQL</option>
    <option value="Oracle">Oracle</option>
    <option value="JCM">Journal of Conceptual Modeling</option>
    <option value="SQL Server Central">SQL Server Central</option>
    <option value="SQL Server Perform">SQL Server Performance</option>
    <option value="SQL Wrox">SQL Wrox</option>
    <option value="SSWUG">SSWUG</option>
    </select>
    </td>
    </tr>
    <tr>
    <td>
    <input TYPE="Submit" NAME="Action" VALUE="Anzeigen" SIZE="20" MAXCHARS="20">
    </td>
    <td>
    <input type="Reset" name="Reset" value="Reset">
    </td>
    </tr>
    </table>
    </form>
    <p>
    <%
    If Request("Action")="Anzeigen" Then
    'On Error Resume Next

    Dim rst
    Dim conn

    Set conn = ConnectDBMS()
    Set rst = Server.CreateObject("ADODB.Recordset")

    SQL = "imm_GetSubjectsFromMailingLists '" & Request("Liste") & "'"
    rst.open SQL, conn

    Do While Not rst.EOF
    %>
    <li>
    <%
    Response.Write "<a class=""frank"" target=""_blank"" href=""mailinglist_det.asp?MsgSubject=" & rst.Fields("MsgSubject") & """>"
    Response.Write rst.Fields("MsgSubject")
    Response.Write "</a>"
    %>
    </li>
    <%
    rst.MoveNext
    Loop
    End If
    %>
    </p>
    </body>
    </html>

    Frank

    http://www.insidesql.de

    http://www.familienzirkus.de

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • If you're only returning one row, use a stored procedure with output parameters for the values you are fetching. This will be faster than using a recordset and will leave you with instantiated command parameters that you can use in HTML.

    --Jonathan



    --Jonathan

  • Thank you for the quick replies and I am sorry if what I sent was a bit vague. I am retrieving multiple records from the database and then retrieving certain fields for the user to identify the correct record. These values are returned to a table, where I want to have a button of some sort, or even an image with a link that selects the specific record and then sends the record ID to another ASP page.

  • Response.Write <a href=" & chr(34) & "editScheduleItem.asp?Submit1=" & cstr(fldvalue) & chr(34) & ">" & cstr(fldvalue) & "</TD></H4>" & chr(13)

    Where fldvalue would be your unique ID Field. Then the page you call would use the request.querystring("Submit1") to retrieve the passed ID. If you need more than one field in your URL, you add a "&" and fieldname between each field.

    for example editstuff.asp?UserID=10&UserName=Bob&UserAge=109

  • Alternatively.. instead of within ASP code, embed ASP parts within html. A bit less efficient but easier to read in my opinion:

    <TD><a href="editScheduleItem.asp?Submit1=<%=fldvalue%>"><%=fldvalue)%></a></TD>

  • Thank you for the ideas,

    I have embedded the html using http header, which has a button embedded within it...it works quite well. I have to admit, I was a little surprised at the complexity, initially I thought it would be easy to pass it through a POST method...but obviously not!

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply