SitePoint Sponsor

User Tag List

Results 1 to 24 of 24
  1. #1
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JAVASCRIPT in ASP

    Code:
    while (!MyQuery.EOF){
    	Response.Write("<tr><td colspan='2' class='results'>" + MyQuery('Title') + "</td>");
    	Response.Write("<td align='right' class='results'> " + MyQuery('Price') + "</td></tr>");
    	MyQuery.MoveNext();
    		}
    I have that returning a record set to display ! I then need to make it so the "Title" is a link to a page with all the information shown for that book! How would i go about doing this ?

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Off Topic:

    Thread moved and more descriptive title added

    Now, do you have a page set up that displays the book information? If so, how does that page know which record to retrieve from the database? Is it a querystring parameter? If so, which one, and how does it map back to your database? This is the kind of info we need to know before we can tell you what to specifically do, but in the general sense all you have to do is add an <a> tag into your response.write statement.

  3. #3
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok bare with me !
    Im a newbie so only just getting to grips with it all.
    Here is the
    Code:
    var conn = Server.CreateObject("ADODB.Connection");
         conn.Provider = "Microsoft.Jet.OLEDB.4.0";
         conn.Open(Server.Mappath("Database/books.mdb"));
    
    var QueryString = "Select * FROM book WHERE " + categoryVar + " LIKE '%" + searchVar + "%' ";
    var MyQuery = conn.execute(QueryString);
    
    while (!MyQuery.EOF){
    	Response.Write("<tr><td colspan='2' class='results'>" + MyQuery('Title') + "</td>");
    	Response.Write("<td align='right' class='results'> " + MyQuery('Price') + "</td></tr>");
    	MyQuery.MoveNext();
    }
    The above is a cut down version of what goes on! It displays the results of book titles along with prices. i then wish on clicking a book that then gets the required record field so can grab all the correct details.
    Make sense ?

    dont know how to do the above then replace the table created above with all the titles and prices with the relevant picture and details from the correct field/set

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    What is the name of your primary key field in the database?

  5. #5
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry what do you mean by primary ?

  6. #6
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by tjsaynor
    sorry what do you mean by primary ?
    You should have something like an ID number for each record in the database. This should be unique to each record (meaning no duplicates in your database table).

  7. #7
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ISBN number is the unique refrence to each field, which is indeed "ISBN"

  8. #8
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is the above what was needed ? Is it i pass this on the end of the URL string?
    url.com?bla=blabla
    Been on this LOL 2 days now as sad as it sounds, did i mention i was a newbie to ASP ?
    Would it at all help if i attach the ASP file and DB

  9. #9
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Yeah, the easiest thing to do is generate a link with a querystring parameter to match the ISBN number.
    Code:
    while (!MyQuery.EOF){
    	Response.Write("<tr><td colspan='2' class='results'><a href='http://www.example.com/bookinfo.asp?isbn=" + MyQuery("ISBN") + "'>" + MyQuery('Title') + "</a></td>");
    	Response.Write("<td align='right' class='results'> " + MyQuery('Price') + "</td></tr>");
    	MyQuery.MoveNext();
    }
    Then check for the ISBN variable on the linked page and show the appropriate information.

  10. #10
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi vgarcia, I had this working a minute a go but have had difficulty for past 30 minutes and im not too sure why?
    There is a fair few lines of code and would look a mess up here? if attach could you please look and advise me what an earth my floor is ?

    I feel like crying taken so long and it broke! its the sending of variables causing the problem! so i have just left the functions in tact! and reomoved triggering them!

    Could you help me how to trigger each one ?

  11. #11
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    im Begging on my knee's, please any one who can lend a helping hand please do so....... i need it so bad.
    This is for education and is my first project in ASP, i am sure simple to most of you guys.
    Please post if you are even taking a look at it, the functions are there but every time i try IF's to say which one to trigger variable errors are thrown at me in the SQL strings!
    Last edited by tjsaynor; Mar 18, 2004 at 05:30.

  12. #12
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The problem is that you've put the database lookup code inside the functions & haven't called them.
    You need to call functions to execute the code they contain. And you call a function like
    [code]
    <%
    displaySelectedBook();
    %>
    [code]

    Unless you call the function, the code it contains will not be executed & hence, you won't get any output.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  13. #13
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No i know that , didnt you see the comments!
    I removed my attempt at calling them but none worked !

    What i mean is try calling them, when needed!
    if there is an ISBNreq variable on the URL then call the displaySelectedBook other wise call the other function there are problems with the functions requiring the variables. The SQL query strings throw up errors

    My head is pounding LOL from this

  14. #14
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I don't think that you get it.
    Where in your code have you checked whether there's something in the querystring variable ISBNreq? So, where are you calling the function? Nowhere. That's where the problem is.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  15. #15
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have i removed this part of the script ?
    Code:
    //******************************************************************************
    // need to call the relevent function 
    // if ISBNreq variable in query string exists display selected book
    // if not do the search with the requested search variables 
    //******************************************************************************
    This is where my attempts previous have been done and failed to call the functions.
    On the version posted up i know i dont call the function as i removed my attempts. reason I was hoping you guys would try it and see the same problem im getting.

  16. #16
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    ok, lets try it then
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  17. #17
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers for looking at this , honeslty really am.

    My code prob needs some altering but if so please indicate what stupid mistakes i have done

  18. #18
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    ok
    here it is.
    Code:
    var qStringSearch = Request.QueryString("ISBNreq");
    var searchVar = Request.Form("searchField");
    var categoryVar = Request.Form("categoryField");
    if(qStringSearch != ""){
    displaySelectedBook();
    }
    if(categoryVar != ""){
    searchAndDisplay();
    }
    just add this bit before the functions begin. & then try calling the page as index.asp?ISBNreq=141187069. It works alright.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  19. #19
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i get this error, have been all the time:
    Code:
    No value given for one or more required parameters.
    /ASP_book_search/index.asp, line 76
    this line is line:
    Code:
    var MyQuery = conn.execute(QueryString);

  20. #20
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    after replacing the above lines?
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  21. #21
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeh DID that last night ! now all new ! funda you at all on MSN ? Say NO if you wish but could do with help through this and ill explain better

  22. #22
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    nah, I'm not on MSN. I mean that I do have an account but I don't use the MSN Messenger & that's why I haven't got it installed.

    But I'm on Yahoo!
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  23. #23
    always learning . . .
    Join Date
    Nov 2003
    Location
    UK
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorted now thanks !
    I tried when you posted that code above and after got the errors the which i posted after !
    It changed nothing for me !

  24. #24
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Glad that its sorted now!!
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!


Bookmarks

Posting Permissions

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