Results 1 to 3 of 3

Thread: how to include id# field of db in url?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    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 Attached Files
    Compare bible texts (and other tools):
    TheWheelofGod

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    Re: how to include id# field of db in url?

    I forgot to add that the url has to be like this on the javascript:
    Code:
    kjvresplistbox.asp?id=<%=rs("id")%>&keyword=<%=keyword%>&keywordb=<%=keywordb%>&keywordc=<%=keywordc%>&keywordd=<%=keywordd%>&keyworde=<%=keyworde%>&keywordf=<%=keywordf%>&keywordg=<%=keywordg%>&keywordh=<%=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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width