473,396 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

submit form with OnClick

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
disabled.
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
CHECK'
onclick='document.frmReview.action='check.asp';doc ument.frmReview.submit()'>
"

thanks!
Jul 19 '05 #1
1 10468
In article <#s**************@tk2msftngp13.phx.gbl>,
SP******************@inspire.net.nz says...
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
robust.

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
Response.Redirect("error.asp")
End If
Call displayOpening(user)
End Select

End Select
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bruce Duncan | last post by:
I can't seem to figure our why this doesn't work. I don't get any errors, it just doesn't submit. Can anyone shed some light. <?PHP $var1 = "http://localhost/php/index.php"; $varx = "bruce";...
4
by: Eric | last post by:
Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works fine, however, when the checkbox is only field...
15
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and...
15
by: JR | last post by:
Hi. I hope someone out there who is more versed with JavaScript than I can help me with the following annoying problem. Here's the problem. I have a form with the following layout: Column A...
6
by: HD | last post by:
Hi. I have an asp page with radio buttons and a combobox... when the user clicks a radio button, I want the form to submit so I can execute the ASP code in order to change the list shown in the...
6
by: charlie_M | last post by:
I figured out via various help from this forum... EXAMPLE: onClick="document.forms.MYBUTTON.value='SIMPLE';document.forms.submit()" In my CGI I see "MYBUTTON" = "SIMPLE" and this works...
4
by: gimme_this_gimme_that | last post by:
Hi, This is sort of a : How to build a Yes/No dialog box qquestion. Or perhaps a question about getting javascript variables from a pop-up window and processing them on a submit. This is...
4
by: Dmitry Korolyov [MVP] | last post by:
When we use btnSubmit.Attributes = "javascript: this.disabled=true;" to make the button disabled and prevent users from clicking it again while form data still posting, there is no longer...
1
by: kkuniya | last post by:
Situation : - A form (method : POST, action : itself, onsubmit : alert 'Submit' ) - Got 2 submit button ( 'Save' , 'View') - Got navigation 1|2|3|4 What I want to do : - Once clicked on the...
10
by: ljlolel | last post by:
So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code. When I submit from my form by pressing the Submit button, I get...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.