submit form with OnClick

Discussion in 'ASP General' started by shank, Aug 6, 2003.

  1. shank

    shank Guest

    I've got 2 problems.
    Problem #1: I have 2 buttons on a form.
    If user clicks on ButtonA, the form gets submitted to PageA.
    If user clicks on ButtonB, the form gets submitted to PageB.
    One forum promotes using the OnClick event to direct to the correct page.
    Another forum says OnClick is not wise because a user could have scripts
    What is the best way?

    Problem #2: What is the proper syntax for the below statement?
    I'm having problems with the OnClick portion.
    Response.write "<input type='submit' name='Submit2' value='I WANT TO MAIL A

    shank, Aug 6, 2003
    1. Advertisements

  2. State Machines was [Re: submit form with OnClick]

    In article <#>,
    > There are a number of ways you could do this. I used to separate out the
    > form page and the processor page because it seemed to keep the code more
    > distinct. Now I tend to post a form back to itself and then do whatever
    > validation or processing is necessary before Response.Redirecting to the
    > next page in the workflow. It's easier than having to come back to the form
    > page after doing the s-side validation in a separate processor script.

    As an old real-time embedded software kind of guy, I attack this problem
    as a classic state machine. It requires adding "state" and "event"
    hidden variables to each displayed page, but I've found it to be pretty

    The traditional "loop forever" construct is replaced by the
    "request/response" mechanism.

    I've built some fairly complex processing procedures around a construct
    like this:

    '~~~~~~~~~~~~~~~~~<State Variable Initialization>~~~~~~~~~~~~~~~~~~
    'If these are null then it means we got here from outside the
    'Test universe. We will count on the "else" cases in our
    'Select statements to fill in the default.
    myState = request("state")
    myEvent = request("event")

    '~~~~~~~~~~~~~~~~~~~~~~~Main Code Starts Here~~~~~~~~~~~~~~~~~~~~~~
    ' This is a state machine that processes the events:
    ' Done - User is done with test subsystem
    ' TakeTest - Take the test
    ' ViewTest - Look at the test (admin/instructor)
    ' GradeTest - Score the test
    ' Cancel - Back out of the current state
    ' Default - Initialization or an unknown event
    ' With respect to the following states:
    ' DisplayingGrade - Test grade is being displayed
    ' GradingTest - Processing student responses
    ' Opening - Are you sure you want to take this test?
    ' TakingTest - Student is taking the test
    ' ViewingTest - Admin/instructor is reviewing the test
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~ States ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    select case myEvent
    case "Cancel"
    Call returnToOpenpage(user.UserType)

    case "Done"
    Call returnToOpenpage(user.UserType)

    case "TakeTest"
    Select Case myState
    Case "Opening"
    Call testGiver(testId, user)
    Case "DisplayingGrade"
    Call returnToOpenpage(user.UserType)
    Case Else
    Call testAborted()
    End Select

    case else
    Select Case myState
    Case "Opening"
    Call displayOpening(user)
    Case Else
    if initializeTest(testId) = False then
    End If
    Call displayOpening(user)
    End Select

    End Select
    Guinness Mann, Aug 6, 2003
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
  2. Randell D.
    Randell D.
    Nov 27, 2003
  3. Andy Goldstein

    onClick, onChange problems with form submit

    Andy Goldstein, Jul 12, 2004, in forum: Javascript
    Thomas 'PointedEars' Lahn
    Jul 14, 2004
  4. Replies:
  5. Dr. Leff