Wrox Programmer Forums
|
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 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 February 19th, 2004, 04:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Then you can't do that on the client side.
You need set some kind of flag or variable to tell your server to run code to delete the records.
Test the flag on the server.
Run the code to delete the records.
Load th epage again.
I have added an example below to illustrate the process.
Note that the first time the page is loaded request("deleteAll") will be empty and the code wont run.


Code:
<% @language = "vbscript" %>
<html>
<head>
    <title>Untitled</title>
</head>
<body>
<%
    'Test the flag
    if request("deleteAll") = "YES" then call DeleteAllRecords
%>
<script language=javascript>
    function checkAll()
    {
      var agree = confirm("Are you sure you want to do this?");
      if (agree)
      //Set the flag to YES if confirmed
      {form1.deleteAll.value='YES';form1.submit();}      
    }
</script>

</script>
<form name="form1" method="POST">
    <input type="button" onclick="checkAll()" value="Check All">
    <input type="hidden" name="deleteAll" value="NO">
</form>
</body>
</html>
<%
    sub DeleteAllRecords()
        'VBScript code goes here to delete records
        Response.write("All Records Deleted")
    end sub
%>
======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old February 19th, 2004, 04:32 AM
Authorized User
 
Join Date: Jan 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default

oooooooo
thanks alot rodmcleay!!!
i modified your example a little to suit my page and it works just fine
thanks!

 
Old February 19th, 2004, 04:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Glad to help but as I said before, this is the basis of ASP, you will need to fully understand it to appreciate the power and limitations of ASP.


======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old February 19th, 2004, 08:26 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Just a few additional suggestions and notes to add to rod's posts here...

I'd recommend always populating the form tag's action attribute. Some browsers won't make the "post to the same page" assumption. I.E. does, but Netscape doesn't. The newer mozillas might. But either way, setting it will make sure it's right. An easy way to do this real quick is this:
<form ... action="<%=Request.ServerVariables("SCRIPT_NAME")% >">
This will ensure that the form always posts back to itself.

Secondly, when you use submit buttons in HTML, only the one you actual click get's posted to the form. For example:

<input type="submit" name="DoThis" value="Do This">
<input type="submit" name="DoThat" value="Do That">

Then in your ASP code you can check to see which button is pressed:

If Request.Form("DoThis")<>"" Then
    'DoThis code
End If
If Request.Form("DoThat")<>"" Then
    'DoThat code
End If

If you click on the "Do This" button, it will get posted to the form (or querystring) data while the "Do That" button won't. This is a really easy way to see which button was pressed without relying on client javascript.

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Not Suppose to offend aasiddle ASP.NET 2.0 Basics 4 March 16th, 2007 11:52 AM
NOT ISPOSTBACK code runs when Back Button clicked Ron Howerton VB.NET 2002/2003 Basics 1 September 28th, 2006 05:12 PM
Solved:VB Code Asks for Password to UnZip!! flashster BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 August 23rd, 2006 01:55 PM
Browser conflicts I suppose . . . Ross McVinnie Intro Programming 0 July 10th, 2006 05:32 PM
VB.NET Edition code problems Solved charul_shukla BOOK: ASP.NET Website Programming Problem-Design-Solution 5 July 11th, 2003 01:56 AM





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