Results 1 to 8 of 8

Thread: Find out which button was clicked

  1. #1

    Thread Starter
    Addicted Member smh's Avatar
    Join Date
    Oct 2000
    Location
    South Dakota, USA
    Posts
    249

    Find out which button was clicked

    I am very new to internet development, so please bear with me.

    There are 3 forms: form1, form2, and report1.

    On form1, I have two buttons, button1 and button2.

    When you select either of these buttons you are sent to form2.

    On form2, there is vbScript to determine which button was selected to determine what is going to happen next. The code to determine which button was selected is not right. How do I fix this?

    if session("CurrentAppl") = "Session1" then
    temp = UpdateInetBankingInfo() 'Updates info submitted on form1

    if Request.Form("button2") = clicked then
    Response.Redirect ("report1.asp")
    end if
    end if
    Normal is boring...

    smh

  2. #2
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    In HTML, give your button a name and a value:
    <input type="submit" name="MyName" value="MyValue">

    Then in ASP:
    If Request.Form("MyName") = "MyValue" Then
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  3. #3

    Thread Starter
    Addicted Member smh's Avatar
    Join Date
    Oct 2000
    Location
    South Dakota, USA
    Posts
    249
    This is what the button is on the first form.

    <input type="button" value="Print Application" id="button2"
    name="btnSubmit2" size="22" onclick="ck_Values()">

    I can not use the type 'submit' because it has to go through data validation before it leaves the page for the new data entered. If I use a submit button and the data is wrong, it will display the error message and leave the form without having the user fix the invalid data.
    Normal is boring...

    smh

  4. #4
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Code:
    <input type="button" value="Print Application1"  name="btnSubmit" onclick="ck_Values()">
    <input type="button" value="Print Application2"  name="btnSubmit" onclick="ck_Values()">
    Code:
    which = Request.Form("btnSubmit")
    'Which will be "Print Application1" or "Print Application2"
    Another way to follow...
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  5. #5

    Thread Starter
    Addicted Member smh's Avatar
    Join Date
    Oct 2000
    Location
    South Dakota, USA
    Posts
    249
    Thanks, worked great.
    Normal is boring...

    smh

  6. #6
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Code:
    <input type="button" name="btnSubmit" onclick="ck_Values(1)">
    <input type="button" name="btnSubmit" onclick="ck_Values(2)">
    Code:
    <script type="text/javascript">
      function ck_Values(which) {
        var which = Number(which);
    
        //Do validation
    
        document.myForm.myHiddenInput.value = which;
        document.myForm.submit;
      }
    </script>
    Code:
    <input type="hidden" name="myHiddenInput" value="">
    All that goes on the same page. The second page asks for Request.Form("myHiddenInput").

    By the way... anyone seen any official documentation on how JavaScript/ECMAScript should handle form elements?
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  7. #7
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Travis, this page

    http://www.w3.org/TR/1998/REC-DOM-Le...-one-html.html

    and the Rhino are what I use. Kind of outdated, but usually gets the job done.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  8. #8
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    All this time I've been looking at the DOM Level 3 Recs. There is stuff in the Level 1 Rec that isn't in the Level 3 Rec. Am I to assume that stuff is still accepted as standard, or has been depreciated?
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

Posting Permissions

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



Click Here to Expand Forum to Full Width