|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
VBScript - Database - General - ASP Database Search
Hi
I have implemented a database search in ASP which returns more than 1 record. I am stuck at how to select 1 record & pass that information to the next page. In the records display after serach I am displaying a radio button along with other columns against each row. Can someone pls help me & give sample code on how to detect which row the user has selected from the results page & pass those columns to the next form. I need sample code plss... Any other approach samples are welcome. Many thanks. |
|
#2
|
||||
|
||||
|
Quote:
you'd be better off posting your own thread or have this post split.... explain more on your setup..ie: only one row is selcted? what is the radio button for? would you except a javascript or a pure asp solution? ...etc
__________________
Please give respect to those that helped solve an issue by clicking on the reputation icon
|
|
#3
|
|||
|
|||
|
Quote:
----------- Hi, Search returns multiple rows User has to select just one row & the radio button is to enable the user to select 1 row returned by the search Javascript or ASP both would be ok.... Thanks |
|
#4
|
||||
|
||||
|
Hi,
If the user only needs to select one row then you dont really need to use radio buttons, you could simply put a button/link next to each row and use the querystring to pass the value of the record, eg: Code:
While NOT rs.EOF
Response.Write("<a href=""nextpage.asp?whichrecord=" & rs.Fields("ID") & """>" & rs.Fields("ID") & "</a><b>Record Details: " & rs.Fields("Column1") & " " & rs.Fields("Column2") & "</b><br>")
rs.MoveNext
Wend
|
|
#5
|
|||
|
|||
|
Quote:
Hi, My code is like this: If Not objrse.EOF Then %> <br> <br> <br> <form method=post action='nextpage.asp' name=searchscript> <table width="100%" border="0" cellpadding="0" cellspacing="10" bgcolor="#F6F6F6"> <thead> <tr> <th align=left> </th> <th align=left>Account Number </th> <th align=left>Name </th> <th align=left>Address </th> </thead> <tbody> <% While Not objrse.EOF %> <tr> <td><input type="Radio" name="selected"></td> <td><%= objrse.Fields("Accountno").Value %></td> <td><%= objrse.Fields("vchAlphaName").Value %></td> </tr> <% objrse.MoveNext Wend %> </tbody> </table> <input class='buttonGradient' type='submit' name='submit' value='Next'> </form> I need to use the post method. Can you help with this code pls....to capture the radio button against a row. Many thanks |
|
#6
|
|||
|
|||
|
Quote:
------------------ Hi, Can you give a sample of the button/link usage that you are talking about Thanks |
|
#7
|
||||
|
||||
|
You just need to make sure that each radio button has a unique value, eg:
Code:
<% While Not objrse.EOF %>
<tr>
<td><input type="Radio" name="selected" value="<%= objrse.Fields("Accountno").Value %>"></td>
<td><%= objrse.Fields("Accountno").Value %></td>
<td><%= objrse.Fields("vchAlphaName").Value %></td>
</tr>
<%
objrse.MoveNext
Wend
%>
</tbody>
</table>
<input class='buttonGradient' type='submit' name='submit' value='Next'>
</form>
Then, you can grab the id of the selected record on the next page with: Code:
<%
Dim whichRecord
whichRecord = Request.Form("selected")
%>
|
|
#8
|
|||
|
|||
|
Quote:
---- Hi, Many thanks for this. If I also have to store the value of "selected" on this page also,how do I do that? |
|
#9
|
||||
|
||||
|
Quote:
I'm not entirely sure what you mean. On the second page you can use the value of Request.Form("selected") to update a record, display data etc. can you give me an example of exactly what you are trying to achieve. |
|
#10
|
|||
|
|||
|
Quote:
-------------- Problem is on the next page there is a variable 'txtacno' which is capturing this value using Request.Form. I cannot modify that next page; So I need to store the selected value(Request.Form("selected")) on this page in a variable so that it can be accessed on the next page without modifying the next page. Thanks |
|
#11
|
||||
|
||||
|
Quote:
Sorry, thats still not really clear. Which page cant you change, nextpage.asp? If you cant change nextpage.asp then I cant see how you can store anything on that page. Sorry for being dull, but can you post all of your code and a full description of your problem so I can see what is going on. <edit> If you have access to nextpage.asp you could store the value of request.form("selected") in a session variable which you can grab on any page. |
|
#12
|
|||
|
|||
|
Quote:
----------- Yes, I cannot change nextpage.asp nextpage.asp already has a code Request.form(temp) From my current page, I need to store the selected value in a variable called 'temp'... Hope this helps. Thanks |
|
#13
|
||||
|
||||
|
You say that nextpage.asp has the code:
Code:
Request.form(temp) Is this exactly as it appears? Or is the word temp surrounded by quotes? |
|
#14
|
|||
|
|||
|
Quote:
---- Sorry,I mean the next page has Request.form("temp") So the selected value on the current page needs to be stored in temp as it is to be referenced in nextpage.asp Thanks |
|
#15
|
||||
|
||||
|
If you cant change the name of the radio button from "selected" to "temp" then I guess a javscript is the only way around this, however I would be reluctant to use javascript as it can be disabled. Heres an example:
Code:
<input type="text" name="temp" value=""></td>
<input class='buttonGradient' type='submit' name='submit' onclick="javascript:getVal();" value='Next'>
<script>
function getVal(){
var selVal = "";
for(var a=0;a<document.searchscript.elements["selected"].length;a++){
var elem=document.searchscript.elements["selected"];
if(elem[a].checked==true){
selVal=elem[a].value;
}
}
document.searchscript.temp.value=selVal;
}
</script>
|
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > VBScript - Database - General - ASP Database Search |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|