Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    South East UK. 35 miles east of London, in sight of the River Thames.
    Posts
    300
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Stopping a search when the page loads

    Hi All,

    I have a single asp page that contains a form with a dropdown box to select a variable in one field of an mdb file.

    The asp code to perform the search is also on this page, along with the code to display the recordset.

    When the page first loads, it always displays the complete database. Once loaded, if I then use the dropdown box, all works perfectly.

    How do I stop this initial search? I have tried using an 'onLoad' function to call a javascript, and:

    If Request.QueryString("cboStatus")<>"live" then
    ... do search ...
    Else
    Response.write("Please make your Selection")
    End If

    to try to stop the search . Nothing stops it as yet.

    Any Idea's?

    Regards

    Gary

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    when you use a multipurpose page, it's best to check at the top of the page, if the page has already been submitted or if this is the initial load. Like
    [code]
    if Len(request.form("search")) > 0 then ' this means there is a value for the formfield named "search"
    run your selectcode and display results
    else
    display the initial form
    end if
    [code]
    --> this supposes you use the post method (<form method="post" ...>) and that your submitbutton has (name="search"). Or you can call the dropdown "search"

    You now probably have a where clause that always evaluates true if there is no value selected (or the where clause isn't add to the query if there was no value selected)

  • #3
    Regular Coder
    Join Date
    Sep 2002
    Location
    South East UK. 35 miles east of London, in sight of the River Thames.
    Posts
    300
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Hi Raf,

    That fixed it.

    To make the form work, I have to use the 'get' function, so I used 'if Len(Request.QueryString) > 0 then' etc, etc.

    I set the initial selected value of the dropdown to empty ("") and now it doesn't trigger a search when the page is loaded.

    Thanks

    Gary


  •  

    Posting Permissions

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