SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    classic asp multiple button click events

    I have a form feedback_administration.asp and feedback_Administration_update.asp

    in feedback_administration.asp I have three submit buttons

    <form ACTION="Feedback_Administration_Update.asp" METHOD=POST NAME="form">
    I have other html part,which am not posting here.

    <input type="button" value="Submit" onclick="javascript:Checkit();" name="btnSubmit">
    <input type="reset" value="Reset" onclick="javascript:document.location=location">
    <input type="button" value="Send Response to Requester" name="btnSubmit" onclick="javascript:Checkit();"/>

    </form>

    my javascript function for checkit()

    function Checkit() {
    var entry_date = document.form.txtentryDt.value;
    var closed_date = document.form.txtclsedDt.value;
    var eDate = new Date(entry_date);
    var cDate = new Date(closed_date);
    var compDate = cDate - eDate;

    if (compDate < 0) {
    alert("Closed date should be greater than Feedback entry date");
    return
    }
    document.form.submit();

    }


    on feedback_Administration_update.asp page

    dim buttonPressed
    buttonPressed=Request.Form("btnSubmit")
    case "Submit"
    <script type="text/javascript" language=javascript>
    alert("submit");
    </script>

    case "Send Response to Requester"
    <script type="text/javascript" language=javascript>
    alert("response");
    </script>
    End Select
    %>

    when I execute,I get to see only the page is redirecting from feedback_Adminsitration.asp tp feedback_Administration_update.asp

    the alert part is not working on click of any button.

    please help on this.

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    OH, USA
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that code will not work because regardless of which button was clicked Request.Form("btnSubmit") will be equal "Submit". it is present in form on first page and never change value...

    modify form like

    Code:
    <form ACTION="Feedback_Administration_Update.asp" METHOD=POST NAME="form">
    <input type="button" value="Submit" onclick="javascript:Checkit('btnSubmit');" name="btnSubmit">
    <input type="reset" value="Reset" />
    <input type="button" value="Send Response to Requester" name="btnSubmit" onclick="javascript:Checkit('Send Response to Requester');"/>
    <input type="hidden" name="whatClicked" value="" />
    </form>
    and change script in first page to

    Code:
    function Checkit(whatClicked) {
    var entry_date = document.form.txtentryDt.value;
    var closed_date = document.form.txtclsedDt.value;
    var eDate = new Date(entry_date);
    var cDate = new Date(closed_date);
    var compDate = cDate - eDate;
    
    if (compDate < 0) {
    alert("Closed date should be greater than Feedback entry date");
    return
    }
    document.form.whatClicked.value=whatClicked;
    document.form.submit();
    
    }

    on second page you can do something like
    Code:
    <%
    
    buttonPressed=Request.Form("whatClicked")
    select case buttonPressed
    case "Submit"
    %>
    <script>
    alert("submit");
    </script>
    <%
    case "Send Response to Requester"
    %>
    <script>
    alert("response");
    </script>
    <%
    End Select
    %>

  3. #3
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your post,

    I did in other way,when I modified the one of the button type to "submit",then it is working ...


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
  •