Click to See Complete Forum and Search --> : HELP - using SQL to display result set in a dynamic form


qaizaar
01-12-2006, 02:00 PM
i query the database and get the result set. now i need to display the result in a html form such that next to each of the rows in the form there is a check box and if the check box is selected the id (which is a unique key in the databse) of the row is stored and sent to another page where it can then be retrieved and then i know what to do from there. Basically this is a form that displays the results of a query and then displays it and when the user chooses to see one of the items from the search result he is taken to another page where the information is displayed. thank you to any one who is able to help me in this.

lmf232s
01-12-2006, 04:24 PM
This is how you can set the value of the checkbox.
<input type=checkbox name="ck_<%=i%>" value="<%=oRS1("KeyId")%>" >

(the name for my checkbox is based on this, if im going to have 25 ckboxes then i will name them differently. I append i to the end of it where i = a number. It starts at 1 and on each loop i increament it by 1. so youll end up with names lik this
ck_1
ck_2
Ck-3
Ck_4 etc.....................)


This is how you can give your checkbox the value of the KeyId your record.
Once you have the value you can pass it to the details page several ways.

You can add an onclick even( or another event) that calls a javascript function which opens a new window and passes the keyid

onclick="ShowDetials("<%=oRS1("KeyId")%>");"

function ShowDetials(num){
window.open('showDetials.asp?id=' + num, '', etc);
}

you could submit the page and get the value of the checked checkbox and then do a response.redirect to that page and then pass the keyid

There are a couple of other ways as well. But basically all you need to do is set the value of the checkbox to that of your keyId then getting the value of the checkbox is as easy as saygin
Request.form("ck?")

Make sense?
I can throw together a little code if you would like.

qaizaar
01-12-2006, 04:53 PM
heres my code :
<tr>
<%
if(res != null)
{
String [] cols = {"Incident ID", "Date", "Requester", "Location", "Type of Incident", "Status", "Category", "Assigned To", "Description"};
for(int i =0; i<cols.length; i++)
{
%>
<td valign="top" align="left" nowrap width="80"><%=cols[i]%>
</td>
<%
}
%>
</tr>

<%
while(res.next())
{
int i = 0;
String memoT = res.getString("memo_for_record");
String workT = res.getString("work_log");
String closureT = res.getString("closure_code_id");
String resoT = res.getString("resolution");
idT = res.getString("incident_id");
java.sql.Timestamp dateT = res.getTimestamp("date_created");
String reqT = res.getString("requester_id");
String locT = res.getString("location");
String inTypeT = res.getString("incident_description");
String desT = res.getString("description");
String stIdT = res.getString("status_code_id");
String assToIdT = res.getString("assigned_to_id");
String catIdT = res.getString("category_id");
%>

<tr>

<td valign="top" align="left" nowrap width="80"><input type="checkbox" name="idCheck" value="ON"><%out.print(idT);
array[i] = idT;%>
</td>
<td valign="top" align="left" nowrap width="80"><%out.print(dateT);%>
</td>
<td valign="top" align="left" nowrap width="80"><%out.print(reqT);%>
</td>
<td valign="top" align="left" nowrap width="80"><%out.print(locT);%>
</td>
<td valign="top" align="left" nowrap width="80"><%out.print(inTypeT);%>
</td>
<td valign="top" align="left" nowrap width="80"><%out.print(stIdT);%>
</td>
<td valign="top" align="left" nowrap width="80"><%out.print(catIdT);%>
</td>
<td valign="top" align="left" nowrap width="80"><%out.print(assToIdT);%>
</td>
<td valign="top" align="left" nowrap width="80"><%out.print(desT);%>
</td>
</tr>
<%
i++;
}
}
else
{
out.print("No Search results were found");
out.print("");
}
state1.close();
con1.close();
//}
%>

so basically i just change the name of the check box every iteration of the while loop and then get the value (which is the value of the idT) and send it to the other page. but how do i send it to the other page? im not very good at scripting so if u could help me with that. but thank u ur idea is excellent

qaizaar
01-12-2006, 05:30 PM
thank you lmf232s. u have been very helpful. i got it, thanks once again

chrismartz
01-12-2006, 05:56 PM
Please only post in one forum with the same question.