Multiple image buttons on same page

Results 1 to 3 of 3

Thread: Multiple image buttons on same page

  1. #1
    Dan Sapon-Borson Guest

    Default Multiple image buttons on same page

    I am using images to serve as buttons on my ASP pages for an intranet where all are on IE4 (thus, using VBScript instead of Java). I&#039m using: "<input type="image" language="vbscript" onclick="call subname()"> I need one "submit" button to submit the form, and another button to be an "abort" button that will delete any information for the current record that has already been saved to the database. I can get the submit button working by calling client-side script that submits the form, but I&#039m not sure how to code the abort button so that it works right.

  2. #2
    Join Date
    Dec 1969

    Default RE: Multiple image buttons on same page

    Your question may need some clarification as this is assuming you aren&#039t using client side recordsets and just using a built HTML page that contains data about one record. First of all, you will need some method of storing the current record ID in your page when you build it. In this case when you looked at the built script it would have a hidden field with the value of the current record id. Example:<BR>&#060;FORM NAME=MYFORM ACTION="SaveRec.ASP" METHOD=POST><BR>&#060;INPUT TYPE=HIDDEN NAME=CURRECID VALUE=15><BR>.<BR>.<BR>&#060;/FORM><BR>In Between the &#060;FORM> and &#060;/FORM> tags you would need to have your buttons for Submitting and Aborting. In this case, a standard submit button would look something like:<BR><BR>&#060;INPUT TYPE=SUBMIT NAME=btnSubmit VALUE="SUBMIT RECORD"><BR><BR>This would do the job of submitting, obviously you would need ASP code to take the form values and ADO code to update the record with the record id stored in the hidden field &#039CURRECID&#039, referenced in ASP code as Request.Form("CURRECID") .<BR>To do the abort button one way would be to include another hidden field when building this page and this might look like:<BR><BR>&#060;INPUT TYPE=HIDDEN NAME="MODE" VALUE="SAVE"><BR><BR>This statement would also go between the &#060;FORM> and &#060;/FORM> tags. The abort button would then just be another submit button with an onSubmit handler that would reset, using script, the value of the hidden "MODE" variable to indicate to the Server side ASP that you have want to delete this record. There are other ways to accomplish the same thing, that is what makes ASP so flexible. That code would be as follows:<BR><BR>&#060;INPUT TYPE=SUBMIT NAME=btnAbort VALUE="Abort" onSubmit="document.myform.MODE.value=&#039ABORT&#0 39"><BR><BR>Notice the use of single quotes. I am not sure if you specify VBScript that that will be allowed. Maybe personal preference but I suggest using JavaScript as it way more flexible than VBScript. VBScript is fine for server-side coding but I use JavaScript for all my client-side coding. Anyway, so when you press the Abort button the script code will set the value of the "MODE" to &#039ABORT&#039 and then will continue submitting automatically. On the server side you can check for the value of the MODE variable with Request.Form("MODE") and if it is equal to "ABORT" then you can execute ADO code to delete the record from the database where the record id is equal to the Request.Form("CURRECID"). If you want more info on ADO code I would be happy to help, I had to make a lot of assumptions as to your problem so if it isn&#039t quite what you were asking for please clarify. Hope this helps.<BR>

  3. #3
    Sam Otto Guest

    Default RE: Multiple image buttons on same page

    You have two options:<BR>1) put the abort button in another form and when it is submitted, it calls a different ASP that does you delete work from the database. You will probably have some hidden input tags in the form to hold what ever info you&#039ll need to remove the correct records.<BR>2) You could do some javascript using the onClick event of the anchor tag around the buttton. <BR><BR>onClick="javascript: myAbortFunction()"<BR><BR>This function could call the ASP page mentioned above (setting document.location in the JS). You probably could set up the full url string back in the ASP code<BR><BR>document.location = "abort.asp?ID=1234"

Posting Permissions

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