Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Add a hyperlink to query results populating form values when clicked


Message #1 by "Charlie Steiner" <e_steiner@h...> on Thu, 18 Oct 2001 22:01:29
Hello,



I have an *.asp page that queries an Access database based on the users 

entry into a form textbox.



The query returns the results into an HTML file which is displayed in the 

browser.



I would like to add a hyperlink to each record that is returned in the 

result set(let's call it results.html).  Once the hyperlink is clicked, 

the browser will display an HTML form (let's call it quote.html)  The 

values for the record whose hyperlink is clicked on results.html should 

populate values on quote.html.  



Thanks for your help,



-Charlie
Message #2 by "Drew, Ron" <RDrew@B...> on Thu, 18 Oct 2001 17:22:41 -0400
Here is some code you can use...start with an html form, pass fields to an

asp and do a request.form for the fields, add the code below which after

querying the db will display all the selections picked with a View

hyperlink.  When the user picks the key field control gets passed to

quote.asp.  You mentioned html, but you need asp to get the data and display

it.



idfield="yourkey"

scriptresponder="quote.asp"

set rstemp=conntemp.execute(mySQL)

howmanyfields=rstemp.fields.count -1

%>

<table align="center" border="1">

<tr>

<td valign="top">&nbsp;&nbsp;&nbsp;</td>

<% 'Put Headings On The Table of Field Names

for i=0 to howmanyfields %>

       <td align=center><b><%=rstemp(i).name %></b></td>

<% next %>

</tr>

<% ' Now lets grab all the records

do  while not rstemp.eof %>

   <tr><td valign="top">

   <%my_link=scriptresponder & "?which=" & rstemp(idfield)%>

   <a HREF="<%=my_link%>">View</a></td>

   <% for i = 0 to howmanyfields%>

          <td valign="top"><%=rstemp(i)%></td>

   <% next %>

   </tr>

   <%

  rstemp.movenext

loop



Message #3 by Simon Newton <simonn@h...> on Fri, 19 Oct 2001 07:24:11 +1000
 Charlie,



 as you build your results page have it create a hyperlink in each RS like

thus



 <a

href=quote.asp?formfield1=<%=rs("appropraite_record")%>&formfield2=<%=rs("ap

propraite_record2")%> etc..etc



note i made your quote page ASP. 



then have the values of your formfields on quote.asp be equal to

request("formfield1") etc etc.



good luck



Simon.  




  Return to Index