Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 10th, 2005, 06:55 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default keyword doesn't appear with result

Can you please check the "keyword"s in the attachment? For some reason it's not coming on top of the iframe as I expected to. Could it be that the "action" in the <form> is missing or what?


Learning of our true origins.

I feel sorry:

http://www.infowars.com/articles/wor...eknowledge.htm

Foreknowledge of A Natural Disaster
Washington was aware that a deadly Tidal Wave was building up in the Indian Ocean
 
Old January 11th, 2005, 12:09 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

Whats this all about???

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
 
Old January 11th, 2005, 12:45 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

I want to highlight the keywords in 6 textboxes in various colors.
page 1:
[code<%
    OPTION EXPLICIT
    Response.Buffer = True
    Response.Expires = 0
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>demo of linked listboxese</title>
</head>
<script language="javascript">
function fillverse(lstSource, lstDest) {
  // look for the selected element in the listbox named by parm "lstSource"
  // find its value... that's a string consisting of
  // chapter number + comma + number of verses
  // our job is to fill in the downstream "lstDest" with integers from 1 to that number
  clearComboOrList(lstDest);
  if (lstSource.selectedIndex > -1) {
    var sVal = lstSource.options[lstSource.selectedIndex].value;
    if (sVal.indexOf(",") > 0) {
      lstDest.options[lstDest.options.length] = new Option("all", "all");
      var arrX = sVal.split(",");
      var numVerses = parseInt(arrX[1]);
      for (var i = 1; i <= numVerses; i++) {
        lstDest.options[lstDest.options.length] = new Option(i);
      }
      if (lstDest.options.length == 0) {
        lstDest.options[lstDest.options.length] = new Option("Make a selection");
      }
    } else lstDest.options[lstDest.options.length] = new Option("Make a selection");
  } else lstDest.options[lstDest.options.length] = new Option("Make a selection");
}
function retrieveverse(lstBook, lstChapter, lstVerse){
  // look in the identified listboxes to find the selected book, chapter, and verse
  // then create a querystring that displays the targeted element in an iframe
  // by calling page showVerse.asp
  if (lstBook.selectedIndex > -1 && lstChapter.selectedIndex > -1 && lstVerse.selectedIndex > -1) {
    var sBook = lstBook.options[lstBook.selectedIndex].value;
    var sChap = lstChapter.options[lstChapter.selectedIndex].text;
    if (!isNaN(sChap)){
      var sVerse = lstVerse.options[lstVerse.selectedIndex].text;
      var sHref = "showVerse.asp?b=" + sBook + "&c=" + sChap + "&v=" + sVerse;
      for (var i = 0; i < document.f1.Keyword.length; i++) {
        var vSearch = document.f1.Keyword[i].value;
        if (vSearch != "") {
          sHref += "&keywords=" +vSearch;
        }
      }
      document.ifrVerse.location.href = sHref;
    }
  }
}
</script>
<body>
<form name="f1">
<table border="1" bgcolor="beige" align="center" xwidth="100%">
<table border="1" width="100%">
  <tr>
    <td width="50%">
      <div align="center">
        <center>

        </center>

    </td>

<table border="1" bgcolor="beige" align="center" xwidth="200%">
<tr><th>book</th><th>chapter</th><th>verse</th></tr>
<tr>
<%
Dim objCon, objList
Set objCon = Server.CreateObject("ADODB.Connection")
objCon.CursorLocation = adUseClient
objCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=" & Server.MapPath("kjv.mdb") & ";" & _
           "User Id=admin;Password="
' create a new chain of listboxes
Set objList = New cDynListbox
Set objList.Connection = objCon
objList.Is2000 = False
' create the primary cell
With objList.NewCell()
  .Size = 5
  .Table = "books"
  .Text = "book_title"
  .Value = "book"
  .Name = "book"
  .StyleInfo = "style='width:150;'"
  .AltOrderField = "book"
End With
' create the secondary cell
With objList.NewCell()
  .Size = 5
  .Name = "chapter"
  .SourceLink = "book"
  .DestLink = "book"
  .Table = "chapters"
  .Text = "chap"
  .Value = "chapmaxv"
  .StyleInfo = "style='width:120;' onchange='fillverse(this,document.f1.verse);' "
End With
%>
    <td><%objList.GetCell(1).Render%></td>
    <td><%objList.GetCell(2).Render%></td>

    <td><select name="verse" size="5" style="width:120;" >
Make a selection</select></td>
        <td><p><input name="f1" type="submit" value=" Search " onclick="retrieveverse(document.f1.book,document.f 1.chapter,document.f1.verse);return(false);">
              <input type="reset" name="B2" value="Clear"></p></td>

</tr>
<tr>
    <td colspan="3">
    <table>
        <tr>
          <td width="50%">&nbsp;<br>
          <b>Text 1</b><br>
            <input size="10" name="Keyword"></td>
          <td width="50%">&nbsp;<br>
            <b>Text 2</b><br>
            <input size="10" name="Keyword"></td>
        </tr>
        <tr>
          <td width="50%">&nbsp;<br>
            <b>Text 3</b><br>
            <input size="10" name="Keyword"></td>
          <td width="50%">&nbsp;<br>
            <b>Text 4</b><br>
            <input size="10" name="Keyword"></td>
        </tr>
        <tr>
          <td width="50%">&nbsp;<br>
            <b>Text 5</b><br>
            <input size="10" name="Keyword"></td>
          <td width="50%">&nbsp;<br>
            <b>Text 3</b><br>
            <input size="10" name="Keyword"></td>
        </tr>
      </table>
    </td>
</tr>
<tr><td align="center" colspan="3"><iframe name="ifrVerse" id="ifrVerse" src="about:blank" style="height:200; width:450;"></iframe></td></tr>

</table>
</form>

<%
Set objList = Nothing
objCon.Close
Set objCon = Nothing
%>
<h2>someone <i>please</i> tell me why I did this</h2>

</body>
</html>[/code]

page 2 (response)
[code<%
    OPTION EXPLICIT
    Response.Buffer = True
    Response.Expires = 0
    Dim objCon
    Dim rs
    Dim sq
    Dim iCounter
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>show an individual verse</title>
</head>
<body>
<%
' prevent sql injection attacks
If Instr(Request("b"), "'") > 0 Or Request("b") = "" Then
  Response.End
ElseIf Instr(Request("c"), "'") > 0 Or Request("c") = ""Then
  Response.End
ElseIf Instr(Request("v"), "'") > 0 Or Request("v") = ""Then
  Response.End
End If
Set objCon = Server.CreateObject("ADODB.Connection")
objCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=" & Server.MapPath("kjv.mdb") & ";" & _
           "User Id=admin;Password="
Set rs = Server.CreateObject("ADODB.Recordset")

If Request("v") = "all" Then
    sq = "select text_data, book_title, chap, vers " & _
        "from bible " & _
        "where book='" & Request("b") & "' " & _
        " and chap=" & Request("c") & _
        " ORDER BY vers"
Else
    sq = "select text_data, book_title, chap, vers FROM bible WHERE "

iCounter = 0
Dim sKeyword
For Each sKeyword in Request("Keywords")
  If Trim(sKeyword) <> "" Then
    sq = sq & "text_data LIKE '%" & sKeyword & "%' AND "
  End If
  iCounter = iCounter + 1
Next

  sq = sq & " book='" & Request("b") & "' " & _
        " and chap=" & Request("c") & _
        " and vers=" & Request("v")
End If
rs.Open sq, objCon%>

<%
If rs.EOF Then
    Response.Write "verse not found: " & request("b") & ", " & Request("c") & ", " & Request("v")
ElseIf IsNull(rs(0)) Then
    Response.Write "verse not found: " & request("b") & ", " & Request("c") & ", " & Request("v")
Else
    Response.Write "Looking for <b>" & Request("Keywords") & "</b>.<br>"
%>
<b><%=rs("book_title")%>&nbsp;&nbsp;<%=rs("chap")% ></b>
<% Do Until rs.EOF
    Response.Write "<p>"
    Response.Write rs("vers")
    Response.Write "&nbsp;&nbsp;" & rs(0) & "</p>"
    rs.MoveNext
  Loop
End If
rs.Close
Set rs = Nothing
objCon.Close
Set objCon = Nothing
%>
</body>
</html>[/code]

include file for highlighting found in showverse.asp
Code:
<SCRIPT LANGUAGE="VBSCRIPT" RUNAT="SERVER">
Function Highlight(strText, strFind, strBefore, strAfter)
  Dim nPos
  Dim nLen
  Dim nLenAll

  nLen = Len(strFind)
  nLenAll = nLen + Len(strBefore) + Len(strAfter) + 1

  Highlight = strText

  If nLen > 0 And Len(Highlight) > 0 Then
    nPos = InStr(1, Highlight, strFind, 1)
    Do While nPos > 0
      Highlight = Left(Highlight, nPos - 1) & _
        strBefore & Mid(Highlight, nPos, nLen) & strAfter &_
         Mid(Highlight, nPos + nLen)

      nPos = InStr(nPos + nLenAll, Highlight, strFind, 1)
    Loop
  End If
End Function
</SCRIPT>
<%
'OPTION EXPLICIT
Dim strText, strFind
strFind=Keyword
strText=RS("text_data")
strText= Highlight(strText, strFind,"<b>", "</b>")
strFind=Keywordb
strText= Highlight(strText, strFind,"<b>", "</b>")
strFind=Keywordc
strText= Highlight(strText, strFind,"<b>", "</b>")
strFind=Keywordd
strText= Highlight(strText, strFind,"<b>", "</b>")
strFind=Keyworde
strText= Highlight(strText, strFind,"<b>", "</b>")
strFind=Keywordf
strText= Highlight(strText, strFind,"<b>", "</b>")
Response.Write strText
%>
I think it has to be rewritten since there was a change in the first two files. It's not working, highlighting the keywords.
here it is:
http://i.domaindlx.com/wheelofgod/tripledemo.asp

Learning of our true origins.

I feel sorry:

http://www.infowars.com/articles/wor...eknowledge.htm

Foreknowledge of A Natural Disaster
Washington was aware that a deadly Tidal Wave was building up in the Indian Ocean





Similar Threads
Thread Thread Starter Forum Replies Last Post
Implements keyword ? SolarEnergy Access VBA 1 August 19th, 2007 10:47 AM
GridView and SQL More than one result = one result DarkForce ASP.NET 2.0 Basics 0 July 20th, 2007 04:29 AM
The "New" Keyword rfarmer VB Components 1 August 16th, 2006 12:18 PM
this keyword RSteel C# 1 December 18th, 2003 04:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.