If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > how to include id# field of db in url?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-28-05, 23:11
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 494
how to include id# field of db in url?

There's a problem with dropdown's name="id" (referring to the id field taken from the value="<%=rs("id")%>").

WHen I change name="id" to name="book" and value="<%=rs("id")%>" to value="<%=rs("book")%>" I would get:
showverse.asp?book=(with the right number with the beginning of that book. But it needs to be more precise, down to the right id)

But if I leave it as "id" although the url will give:
showverse.asp?id=(with the right number but goes to the very first book and chapter)

Code:
<form name="books" action="showverse.asp" method="get" target="ifrVerse">

<select name="id" size="10" style="width:200;" onchange="go1();">

                    <%
                    Do until RS.eof
                        %>
                        <option selected value="<%=RS("id")%>"><%=RS("Book_Title")%>&nbsp;<%=RS("Chapter")%>:<%=RS("Verse")%></option>
                        <%
                        RS.movenext
                        if RS.eof then
                            exit do
                        end if
                    loop
                    %>
                    </select>

        </td>

                 <tr>
                 <td align="center">
                 <input type="submit" value=" Search ">
                 <input type="Reset" value=" Clear the words ">
                 </td>
                 </tr>
			
</form>
attachment is the action="showverse.asp" in .txt
Attached Files
File Type: txt showversea.txt (6.3 KB, 54 views)
__________________
Compare bible texts (and other tools):
TheWheelofGod
Reply With Quote
  #2 (permalink)  
Old 12-29-05, 17:21
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Why not do something like this?? Note the 'pipe' between the id and the book fields.....
Code:
<form name="books" action="showverse.asp" method="get" target="ifrVerse">

<select name="id" size="10" style="width:200;" onchange="go1();">

                    <%
                    Do until RS.eof
                        %>
                        <option selected value="<%=RS("book")%>|<%=RS("id")%>"><%=RS("Book_Title")%>&nbsp;<%=RS("Chapter")%>:<%=RS("Verse")%></option>
                        <%
                        RS.movenext
                        if RS.eof then
                            exit do
                        end if
                    loop
                    %>
                    </select>

        </td>

<tr>
         <td align="center">
             <input type="submit" value=" Search ">
             <input type="Reset" value=" Clear the words ">
         </td>
</tr>
</form>
So in your show verse page you can do something like
Code:
values = request("id")
arrValues() = values.Split("|")
id = arrValues(0)
book = arrValues(0)
HTH. Syntax may not be right but I'm sure after all these months you will be able to figure it out.

Good to see you still around. Hope you had a good Xmas.
Reply With Quote
  #3 (permalink)  
Old 12-29-05, 18:21
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 494
Thanks rokslide. Happy New Year.

If name="id" then the url will show ?id= .
If there's a way to display the id alone on the url I'll be satisfied. But what it's doing is showing the very first chapter of the very first book. It's not even giving the proper result listed on the url.

If that doesn't work then the next option is to have:
?book=23&chapter=85&verse=32
__________________
Compare bible texts (and other tools):
TheWheelofGod
Reply With Quote
  #4 (permalink)  
Old 12-29-05, 18:38
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 494
Ok so I did:
Code:
<form name="books" action="showversea.asp" method="get" target="ifrVerse">
<select name="id" size="10" style="width:200;" onchange="go1();">

                    <%
                    Do until RS.eof
                        %>
                        <option selected value="<%=RS("id")%>"><%=RS("Book_Title")%>&nbsp;<%=RS("Chapter")%>:<%=RS("Verse")%></option>
                        <%
                        RS.movenext
                        if RS.eof then
                            exit do
                        end if
                    loop
                    %>
                    </select>

        </td>

                 <tr>
                 <td align="center">
                 <input type="submit" value=" Search ">
                 <input type="Reset" value=" Clear the words ">
                 </td>
                 </tr>
			
</form>
Code:
dim values
values = request("id")
arrValues() = values.Split("|")
id = arrValues(0)
'book = arrValues(0)
But I got:
Quote:
Microsoft VBScript runtime error '800a01a8'

Object required: '4894'

/wheelofgod/showversea.asp, line 124
__________________
Compare bible texts (and other tools):
TheWheelofGod
Reply With Quote
  #5 (permalink)  
Old 12-29-05, 19:01
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
okie, forget everything I said.... I just looked at the attachment.... the problem would appear to me that you are not actually using Id in any of your databae queries... atleast not that I can see (it's a bit hard to make stuff out when there is no indenting of any kind).
Reply With Quote
  #6 (permalink)  
Old 12-30-05, 09:42
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 494
I don't understand why id doesn't work.
Attached Files
File Type: txt showversea.txt (858 Bytes, 50 views)
__________________
Compare bible texts (and other tools):
TheWheelofGod

Last edited by gilgalbiblewhee; 12-30-05 at 10:15.
Reply With Quote
  #7 (permalink)  
Old 12-30-05, 11:46
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 494
Ok I see what went wrong. I modified this:
Code:
id=Request("id")


'This SQL statement creates a list of books
SQL1 = "Select * FROM Bible WHERE id = " & id & " ORDER BY id ASC"

rs.Open sql1,conn, 1
How can I have two dropdowns side-by-side with the same results through asp?
As you see the first dropdown is full and the 2nd empty:
Code:
<td>
<form name="booksa" action="showversea.asp" method="get" target="ifrVerse">
<select name="id" size="10" style="width:200;" onchange="go1();">

                    
                        <option  value="4894">Deuteronomy&nbsp;1:1</option>
                        
                        <option  value="1911">Exodus&nbsp;14:21</option>
                        
                        <option  value="1916">Exodus&nbsp;14:26</option>

                        
                        <option  value="1917">Exodus&nbsp;14:27</option>
                        
                        <option  value="1922">Exodus&nbsp;15:1</option>
                        
                        <option  value="1943">Exodus&nbsp;15:22</option>
                        
                        <option  value="2026">Exodus&nbsp;18:26</option>
                        
                        <option  value="3204">Leviticus&nbsp;16:2</option>

                        
                        <option  value="3940">Numbers&nbsp;7:89</option>
                        
                        <option  value="4145">Numbers&nbsp;14:36</option>
                        
                        <option  value="10964">1 Chronicles&nbsp;21:29</option>
                        
                        <option  value="18878">Isaiah&nbsp;63:11</option>
                        
                        <option  value="23921">Matthew&nbsp;23:2</option>

                        
                        <option  value="28570">1 Corinthians&nbsp;10:2</option>
                        
                    </select>
        </td>

                 <tr>
                 <td align="center">
                 <input type="submit" value=" Search ">
                 <input type="Reset" value=" Clear the words ">

                 </td>
                 </tr>
			
</form>		
</td>

<tr>
<form name="booksb" action="showversea.asp" method="get" target="ifrVerse2">
<select name="id" size="10" style="width:200;" onchange="go1();">

                    
                    </select>
        </td>

                 <tr>
                 <td align="center">
                 <input type="submit" value=" Search ">
                 <input type="Reset" value=" Clear the words ">
                 </td>
                 </tr>
			
</form>		
</tr>
__________________
Compare bible texts (and other tools):
TheWheelofGod
Reply With Quote
  #8 (permalink)  
Old 12-30-05, 20:01
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 494
I did a Do Loop and it worked. I used x in between and when x < 1 it would write the first dropdown along with other things. And when x > 1 it would write the 2nd dropdown and end the page.

The problem now is an iFrame issue. The page kjvresp.asp has two iFrames. And within each iFrame there is another iFrame (I haven't used the first level of iFrames, only the second level.) The problem is that the fisrt dropdown is opening in the 1st iFrame but the 2nd dropdown opens in a new window instead of opening in the 2nd iFrame.

Code:
<table>
<td>
<form name="booksa" action="showversea.asp" method="get" target="ifrVerse">
<select name="id" size="10" style="width:200;" onchange="go1();">

                    
                        <option  value="4894">Deuteronomy&nbsp;1:1</option>
                        
                        <option  value="1911">Exodus&nbsp;14:21</option>
                        
                        <option  value="1916">Exodus&nbsp;14:26</option>

                        
                        <option  value="1917">Exodus&nbsp;14:27</option>
                        
                        <option  value="1922">Exodus&nbsp;15:1</option>
                        
                        <option  value="1943">Exodus&nbsp;15:22</option>
                        
                        <option  value="2026">Exodus&nbsp;18:26</option>
                        
                        <option  value="3204">Leviticus&nbsp;16:2</option>

                        
                        <option  value="3940">Numbers&nbsp;7:89</option>
                        
                        <option  value="4145">Numbers&nbsp;14:36</option>
                        
                        <option  value="10964">1 Chronicles&nbsp;21:29</option>
                        
                        <option  value="18878">Isaiah&nbsp;63:11</option>
                        
                        <option  value="23921">Matthew&nbsp;23:2</option>

                        
                        <option  value="28570">1 Corinthians&nbsp;10:2</option>
                        
                    </select>
        </td>

                 <tr>
                 <td align="center">
                 <input type="submit" value=" Search ">
                 <input type="Reset" value=" Clear the words ">

                 </td>
                 </tr>
			
</form>		
</td>

<td>
<form name="booksb" action="showversea.asp" method="get" target="ifrVerse2">
<select name="id" size="10" style="width:200;" onchange="go1();">

                    
                        <option  value="4894">Deuteronomy&nbsp;1:1</option>
                        
                        <option  value="1911">Exodus&nbsp;14:21</option>
                        
                        <option  value="1916">Exodus&nbsp;14:26</option>

                        
                        <option  value="1917">Exodus&nbsp;14:27</option>
                        
                        <option  value="1922">Exodus&nbsp;15:1</option>
                        
                        <option  value="1943">Exodus&nbsp;15:22</option>
                        
                        <option  value="2026">Exodus&nbsp;18:26</option>
                        
                        <option  value="3204">Leviticus&nbsp;16:2</option>

                        
                        <option  value="3940">Numbers&nbsp;7:89</option>
                        
                        <option  value="4145">Numbers&nbsp;14:36</option>
                        
                        <option  value="10964">1 Chronicles&nbsp;21:29</option>
                        
                        <option  value="18878">Isaiah&nbsp;63:11</option>
                        
                        <option  value="23921">Matthew&nbsp;23:2</option>

                        
                        <option  value="28570">1 Corinthians&nbsp;10:2</option>
                        
                    </select>
        </td>

                 <tr>
                 <td align="center">
                 <input type="submit" value=" Search ">
                 <input type="Reset" value=" Clear the words ">

                 </td>
                 </tr>
			
</form>		
</td>

</table>
<td>
<iframe
src ="/wheelofgod/kjvresplistboxa.asp"
width="300" height="1200" name="ifrverse" id="ifrVerse">
</iframe>
</td>
<td>
<iframe
src ="/wheelofgod/kjvresplistboxb.asp"
width="300" height="1200" name="ifrverse2" id="ifrVerse2">
</iframe>
</td>
__________________
Compare bible texts (and other tools):
TheWheelofGod
Reply With Quote
  #9 (permalink)  
Old 12-31-05, 17:44
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 494
not opening in iFrame

Here are the three files. Unless you know what you're looking for you'll be lost.
kjvresp.asp has the two dropdowns and a pair of iFrames.

Within the first iFrames there is kjvresplistbox.asp. It has an iFrame within itself.

Within the iFrame there is showversea.asp. showversea.asp is where there is the result. The problem is that the first opens correctly within the showversea.asp iFrame, but the second opens in a separate page.
Attached Files
File Type: zip 3files.zip (6.5 KB, 25 views)
__________________
Compare bible texts (and other tools):
TheWheelofGod
Reply With Quote
  #10 (permalink)  
Old 01-05-06, 17:51
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 494
reorganized code - easier to read

reorganized code - easier to read
How do you make the dropdown go to the javascript to write the address of the url to be opened and what's wrong (recycled code) with the javascript?

Code:
<% 'Option Explicit
Response.Buffer=false%>
<%
Const DB_NAME           = "kjv.mdb" ' Name of our database file
Const INTRO             = "introduction to the wheelofgod.asp"
Const THECYCLES         = "cycles.asp"
Const SCRIPT_NAME       = "kjv.asp"  ' Name of this script
Const SCRIPT_NAMES      = "kjvresp.asp"
const SCRIPT_SAVED      = "redirect.asp"
Const SCRIPT_FEEDBACK   = "mailto.asp"
Const SCRIPT_TEXT       = "bibletext.asp"

Const RECORDS_PER_PAGE  = 10            ' Number of records per page

Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adCmdTableDirect = &H0200
Const adUseClient = 3

Private Function GetConnectionString()
	GetConnectionString =   "Driver={Microsoft Access Driver (*.mdb)};" & _
		"DBQ=" & Server.MapPath(DB_NAME) & ";" & _
		"UID=;PWD=;"
End Function

Set Conn = server.createobject("ADODB.Connection")
Conn.open GetConnectionString

Dim x
x=0
do until x = 2
%>

<!--#include file=query.asp-->

<%
set RS = Server.CreateObject("ADODB.Recordset")
rs.PageSize= RECORDS_PER_PAGE
rs.CursorLocation = adUseClient
rs.CacheSize = 20
RS.Open SQL, Conn, adOpenForwardOnly, adLockReadOnly

rscount=rs.RecordCount
rspage=rs.PageCount

if request.querystring("page")="" then 
		page=1
	else
   		page=cint((request.querystring("page")))
end if

if x < 1 then
	response.write sql
	%>
	</br>
	<!--#include file="kingjamespagetop.txt"-->
	
	<script language="JavaScript" type="text/javascript">
	<!--
		function go1(){
			location = "kjvresplistbox.asp?id=" + document.myForm.id.options[document.myForm.id.selectedIndex].value + "&Keyword=" + document.myForm.Keyword.value + "&Keywordb=" + document.myForm.Keywordb.value + "&Keywordc=" + document.myForm.Keywordc.value + "&Keywordd=" + document.myForm.Keywordd.value + "&Keyworde=" + document.myForm.Keyworde.value + "&Keywordf=" + document.myForm.Keywordf.value + "#bcv"
            }
		function go2(){
			location = "kjvresplistbox.asp?Book=<%=Book%>&Chapter=" + document.myForm.Chapter.options[document.myForm.Chapter.selectedIndex].value + "&Keyword=" + document.myForm.Keyword.value + "&Keywordb=" + document.myForm.Keywordb.value + "&Keywordc=" + document.myForm.Keywordc.value + "&Keywordd=" + document.myForm.Keywordd.value + "&Keyworde=" + document.myForm.Keyworde.value + "&Keywordf=" + document.myForm.Keywordf.value + "#bcv"
			}
	//-->
	</script>
	
	<%
	If Not rs.EOF Then
	Response.Write "The King James Bible has <b>" & rs.RecordCount &_
	"</b> verses matching "

		If Trim(Keyword & "") <> "" Then 
			%> 
			<font color="red"><b><%=Keyword%></b></font><% 
		End If 
		If Trim(Keywordb & "") <> "" Then 
			%> 
          	&nbsp;+&nbsp;<font color="blue"><b><%=Keywordb%></b></font><% 
		End If 
		If Trim(Keywordc & "") <> "" Then 
			%> 
			&nbsp;+&nbsp;<font color="green"><b><%=Keywordc%></b></font><% 
		End If 
		If Trim(Keywordd & "") <> "" Then 
			%> 
        	&nbsp;+&nbsp;<font color="orange"><b><%=Keywordd%></b></font><% 
		End If 
			If Trim(Keyworde & "") <> "" Then 
			%> 
          	&nbsp;+&nbsp;<font color="purple"><b><%=Keyworde%></b></font><% 
		End If 
		If Trim(Keywordf & "") <> "" Then 
			%> 
          	&nbsp;+&nbsp;<font color="aqua"><b><%=Keywordf%></b></font><% 
		End If
			If Trim(Keywordg & "") <> "" Then
			%> 
          	&nbsp;+&nbsp;<font color="aqua"><b><%=Keywordg%></b></font><%
		End If
		If Trim(Keywordh & "") <> "" Then
			%>
          &nbsp;+&nbsp;<font color="aqua"><b><%=Keywordh%></b></font><%
		End If   
		'spoke = Request.Querystring("spoke") 
		If Trim(spoke & "") <> "" Then 
			%> 
        &nbsp;in&nbsp;SPOKE&nbsp;<b><%=spoke%></b><% 
		End If
		If Trim(number & "") <> "" Then
    		if request.QueryString("book_title")="yes" then 
      			Response.Write "&nbsp;in&nbsp;<b>" & rs("book_title") & "</b>" 
    		end if
    		if request.QueryString("book")="yes" then 
      			Response.Write "&nbsp;in&nbsp;book <b>" & number & "</b>"
    		end if
    		if request.QueryString("chapter")="yes" then 
      			Response.Write "&nbsp;in&nbsp;chapter <b>" & number & "</b>"
    		end if
    		if request.QueryString("verse")="yes" then 
      			Response.Write "&nbsp;in&nbsp;verse <b>" & number & "</b>"
    		end if 

		End If
	Response.Write ".</p>"
	Response.Write "</br>There are " & rs.PageCount & " page(s) of result(s).</br>"
	Response.Write "The current page is " & Page & ".<p>"
	End if

end if
'<!--#include file=pagingrecordsets.asp-->
%>
<%If rs.BOF and rs.EOF Then%>
		<H2 align="center">
		We did not find a match of <i><b>
		"<%=Keyword%>"&nbsp;
		"<%=Keywordb%>"&nbsp;
		"<%=Keywordc%>"&nbsp;
		"<%=Keywordd%>"&nbsp;
		"<%=Keyworde%>"&nbsp;
		"<%=Keywordf%>"&nbsp;
		"<%=Keywordg%>"&nbsp;
		"<%=Keywordh%>"!</b></i></H2>
		<h5 align=center><A HREF="<%=SCRIPT_FEEDBACK%>">Feedback Forum</A>      |
		<A HREF="<%=SCRIPT_NAME%>">Back To Search Page</A></h5>

	<%Else
	
	'<table border="1" cellspacing="1" bgcolor="#0066CC">
	'<tr style="height:12.75pt">
	'<!--#include file=sort.asp-->

	'<!--#include file=tableofresults.asp--> 

	'</table>%>
<%end if%>
<table>
<table>
<%
Dim Book
Dim Chapter
Dim Verse
Dim DSNName
Dim Conn
Dim SQL1
Dim pagingurl

if x<1 then
	%>
	<tr>
	<td>
		<form name="booksa" action="showversea.asp" method="get" target="ifrVerse">
		<select name="id" size="10" style="width:200;" onchange="go1();">
			<%
			Do until RS.eof
			%>
				<option <%if Request.QueryString("id")=RS("id") then response.write "selected" %> value="<%=RS("id")%>"><%=RS("Book_Title")%>&nbsp;<%=RS("Chapter")%>:<%=RS("Verse")%></option>
				<%
					RS.movenext
					if RS.eof then
						exit do
                    end if
			loop
				%>
		</select>
	</td>
	</tr>

	<tr>
		<td>
			<input type="submit" value=" Search ">
			<%'<input type="Reset" value=" Clear the words ">%>
		</td>
	</tr>
			
	</form>		
	</td>
<%
end if
x = x + 1
if x>1 then

%>
	<tr>
	<td>
	<form name="booksb" action="showversea.asp" method="get" target="gaga">
	<select name="id" size="10" style="width:200;" onchange="go1();">
		<%
		Do until RS.eof
		%>
			<option <%if Request.QueryString("id")=RS("id") then response.write "selected" %> value="<%=RS("id")%>"><%=RS("Book_Title")%>&nbsp;<%=RS("Chapter")%>:<%=RS("Verse")%></option>
		<%
			RS.movenext
			if RS.eof then
				exit do
			end if
		loop
		%>
	</select>
	</td>
	</tr>
	<tr>
		<td>
			<input type="submit" value=" Search ">
			<%'<input type="Reset" value=" Clear the words ">%>
		</td>
	</tr>
	</form>		
	
	<%
end if
loop%>
</table>


<td>
<iframe
src ="/wheelofgod/kjvresplistbox.asp"
width="300" height="1200" name="ifrverse" id="ifrVerse">
</iframe>
</td>

<td>
<iframe
src ="/wheelofgod/kjvresplistbox.asp"
width="300" height="1200" name="gaga" id="gaga">
</iframe>
</td>

</table>
<%
'<!--#include file=pagingrecordsets.asp--> 
 rs.Close()%>
<!--#include file="kingjamespagebottom.txt"-->
__________________
Compare bible texts (and other tools):
TheWheelofGod

Last edited by gilgalbiblewhee; 01-05-06 at 17:58.
Reply With Quote
  #11 (permalink)  
Old 01-05-06, 18:14
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 494
I forgot to add that the url has to be like this on the javascript:
kjvresplistbox.asp?id=<%=rs("id")%>&keyword=<%=key word%>&keywordb=<%=keywordb%>&keywordc=<%=keywordc %>&keywordd=<%=keywordd%>&keyworde=<%=keyworde%>&k eywordf=<%=keywordf%>&keywordg=<%=keywordg%>&keywo rdh=<%=keywordh%>

basically id is from the database field, and keyword and keywordb-keywordh are the keywords searched for.
__________________
Compare bible texts (and other tools):
TheWheelofGod
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On