Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 5th, 2006, 07:30 PM
Friend of Wrox
Points: 1,107, Level: 13
Points: 1,107, Level: 13 Points: 1,107, Level: 13 Points: 1,107, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: , , .
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default 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
%>



<%
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>


    <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 
            %> 
            <b><%=Keyword%></b><% 
        End If 
        If Trim(Keywordb & "") <> "" Then 
            %> 
              &nbsp;+&nbsp;<b><%=Keywordb%></b><% 
        End If 
        If Trim(Keywordc & "") <> "" Then 
            %> 
            &nbsp;+&nbsp;<b><%=Keywordc%></b><% 
        End If 
        If Trim(Keywordd & "") <> "" Then 
            %> 
            &nbsp;+&nbsp;<b><%=Keywordd%></b><% 
        End If 
            If Trim(Keyworde & "") <> "" Then 
            %> 
              &nbsp;+&nbsp;<b><%=Keyworde%></b><% 
        End If 
        If Trim(Keywordf & "") <> "" Then 
            %> 
              &nbsp;+&nbsp;<b><%=Keywordf%></b><% 
        End If
            If Trim(Keywordg & "") <> "" Then
            %> 
              &nbsp;+&nbsp;<b><%=Keywordg%></b><%
        End If
        If Trim(Keywordh & "") <> "" Then
            %>
          &nbsp;+&nbsp;<b><%=Keywordh%></b><%
        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
'
%>
<%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">
    '

    ' 

    '</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>
<%
' 
 rs.Close()%>
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%>
Code:

 basically id is from the database field, and keyword and keywordb-keywordh are the keywords searched for.

Martial Law 9/11 Rise of the Police State is now available! Visit our Martial Law movie section for complete info (click here), or order now by clicking the button below or by calling 888-253-3139
http://www.infowars.com/martial_law_911.htm
Reply With Quote
  #2 (permalink)  
Old January 5th, 2006, 08:02 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

mmmm, your post is interesting.

FYI:
1..To get the most efficient help from a forum you should post problematic code only.
2..If your problem is JS place it in the JS area
3..You say:
   ;;;reorganized code - easier to read
   If you are looking for somebody to reorganize, you ask to much and I doubt it will happen. This is an area for troubleshooting SPECIFIC problems...


;;;How do you make the dropdown go to the javascript to write the address of the url to be opened

Place an event inside the select tag calling a function:
<select ... onChange="someName();">

This calls a function:
function someName()
{
   //this line overrides the action property inside the <form> tag
   formName.action = 'pageName.asp?id=someValue';
   //submits the form
   formName.submit();
}

;;;what's wrong (recycled code) with the javascript
This is not the JS forum. You want JS gurus go there.

IMO:
Get rid of all thos querystrings, use hidden form fields, post your values

;;;I forgot to add that the url has to be like this on the javascript
It doesnt have to be. I would use method="post" in your <form> tag and post hidden and or visible values to your destination page.

Are these keywords user defined? If so and you intend passing them in the URL you are going to have to validate and probably URLEncode some values - can see all sorts of potential problems with your page design.

Wind is your friend
Matt
Reply With Quote
  #3 (permalink)  
Old January 5th, 2006, 08:43 PM
Friend of Wrox
Points: 1,107, Level: 13
Points: 1,107, Level: 13 Points: 1,107, Level: 13 Points: 1,107, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: , , .
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sorry for posting the wrong place. Since the problem had also to do with asp I should post it here. I'll be more carefull next time.

I had a question though:

Code:
        function go1()
                {
        booksa.action = 'showversea.asp?id=';
        booksa.submit();
                }


How can I add "&keyword="....?
How can I add "&keyword="....?
Is ' ' necessary or I can use " "?


Martial Law 9/11 Rise of the Police State is now available! Visit our Martial Law movie section for complete info (click here), or order now by clicking the button below or by calling 888-253-3139
http://www.infowars.com/martial_law_911.htm
Reply With Quote
  #4 (permalink)  
Old January 5th, 2006, 08:48 PM
Friend of Wrox
Points: 1,107, Level: 13
Points: 1,107, Level: 13 Points: 1,107, Level: 13 Points: 1,107, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: , , .
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

Oh no. I posted in a new thread.

Martial Law 9/11 Rise of the Police State is now available! Visit our Martial Law movie section for complete info (click here), or order now by clicking the button below or by calling 888-253-3139
http://www.infowars.com/martial_law_911.htm
Reply With Quote
  #5 (permalink)  
Old January 5th, 2006, 08:50 PM
Friend of Wrox
Points: 1,107, Level: 13
Points: 1,107, Level: 13 Points: 1,107, Level: 13 Points: 1,107, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: , , .
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

http://p2p.wrox.com/topic.asp?TOPIC_ID=38356

Martial Law 9/11 Rise of the Police State is now available! Visit our Martial Law movie section for complete info (click here), or order now by clicking the button below or by calling 888-253-3139
http://www.infowars.com/martial_law_911.htm
Reply With Quote
  #6 (permalink)  
Old January 5th, 2006, 10:45 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

With JS you cancantenate using the + where as ASP uses the &

NOTE: JS is case and space sensitive unlike ASP and VBScript

What would I do:

<select ... onChange="go1('oneValue', 'anotherValue');">

Then in your function:

function go1(someVarName,someOtherVarName)
{
   booksa.action = 'showversea.asp?id=' + someVarName + '&xyz=' + someOtherVarName;
   booksa.submit();
}

Yes use '' and not ""

HTH

Wind is your friend
Matt
Reply With Quote
  #7 (permalink)  
Old January 5th, 2006, 10:54 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Another comment - If I were you I would place all my JS functions after the <head> and before your </head> I believe this is good practice however I am no JS guru (thats what the JS area of the forum is for)


Wind is your friend
Matt
Reply With Quote
  #8 (permalink)  
Old January 5th, 2006, 11:07 PM
Friend of Wrox
Points: 1,107, Level: 13
Points: 1,107, Level: 13 Points: 1,107, Level: 13 Points: 1,107, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: , , .
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

Is this how it's done? It's not working.
Code:
        var identity
        var keyword
        function go1(identity,keyword)
        {
           booksa.action = 'showversea.asp?id=' + identity + '&keyword=' + keyword;
           booksa.submit();
        }
Martial Law 9/11 Rise of the Police State is now available! Visit our Martial Law movie section for complete info (click here), or order now by clicking the button below or by calling 888-253-3139
http://www.infowars.com/martial_law_911.htm
Reply With Quote
  #9 (permalink)  
Old January 8th, 2006, 06:26 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;It's not working.

Help others help you:
1..I assume from what you have posted it is a client side error?
2..What is the error?
3..What line number?
4..Is the function being run (the test below will tell you) perhaps the event is not being fired.
This would mean the JS error will be pointing to the line where your function is being called.

Post the html tag where you call the function in addition to the function.

You do not need to declaire the following two variables:
var identity
var keyword

Lets test n see if values are coming thru:

function go1(identity,keyword)
{
   alert(identity);
   alert(keyWord);
   booksa.action = 'showversea.asp?id=' + identity + '&keyword=' + keyword;
   booksa.submit();
}

Are the values being alerted?



Wind is your friend
Matt
Reply With Quote
  #10 (permalink)  
Old January 19th, 2006, 04:12 PM
Friend of Wrox
Points: 1,107, Level: 13
Points: 1,107, Level: 13 Points: 1,107, Level: 13 Points: 1,107, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: , , .
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

Can you check if this is correct?

Code:
        function go1(identity,keyword)
        {
           alert(identity);
           alert(keyword);
           booksa.action = 'showversea.asp?id=' + identity + '&keyword=' + keyword;
           booksa.submit();
        }

And
Code:
        <select name="id" size="10" style="width:200;" onchange="go1(identity,keyword);">
I got two JS errors: Identity is undefined and object expected on line 24 (is line 24 from the "view source" or including the asp codes? If it's from the "view source" I have to admit that I've included a file in that page which is above the Javascript code which has the left hand column list. Therefore the Javascript is in the <body>)

Martial Law 9/11 Rise of the Police State is now available! Visit our Martial Law movie section for complete info (click here), or order now by clicking the button below or by calling 888-253-3139
http://www.infowars.com/martial_law_911.htm
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
New and reorganized categories and forum topics jminatel Forum and Wrox.com Feedback 5 July 15th, 2010 06:05 AM
need sample code for read txt file lawsoncobol Access VBA 4 July 16th, 2007 08:30 AM
Easier page navigation of search results gs99 Forum and Wrox.com Feedback 0 February 2nd, 2007 09:38 PM
Read first!!!: Where is the code for a Wrox book jminatel All Other Wrox Books 0 March 17th, 2004 04:43 PM
Read first!!!: Where is the code for a Wrox book jminatel Wrox Book Feedback 0 September 15th, 2003 11:30 AM



All times are GMT -4. The time now is 12:22 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.