473,584 Members | 2,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form submission problem

Hi,

I am just starting to work with ASP, so bear that in mind...

I have an ASP page that displays records from a table, and
allows you to add, update and delete. There is a form with
one button that does adds and updates, and a second button
for deletes.

What I want to do is, instead of having the 'action' of the
form be something like:

action="updateU ser.asp?mode=up date"

I want to use the onClick property of Add/Update and Delete
buttons to set a value in a hidden field in the table, and NOT
have a query string, ie: action="updateU ser.asp"

The problem is that I have an 'If' statement to determine if
I need to do an add/update/delete or just display the records
and form:

If (Request.Form(" txtAction") = "update" Or
Request.Form("t xtAction") = "delete") Then

do some stuff...

End If

The problem is that when it runs, and the page is first
displayed, I get:

Error Type:
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/dms/updateUser.asp, line 49, column 43
If (Request.Form(" txtAction") = "update" Or
------------------------------------------^
This makes sense if you can't include a form field in
an If statement before the form has even been defined.
So I put an If statement before it to determine that case:

If Request.Form.Co unt > 0 Then
Is there a better way to do this? Is there something
obviously wrong with the If statement?

tia,
Bill
Jul 19 '05 #1
2 3405
This is one way of changing the form action using javascript:

<script language="JavaS cript">
// Changes the form txtAction variable and submits the form
function chgAction(m_act ion){
document.formna me.txtAction = m_action;
document.formna me.submit();
}
</script>

<form name="formname" action="updateU ser.asp">
<input type="hidden" name="txtAction " value="">

blah-blah

<input type="button" value="Add"
onClick="javasc ript:chgAction( 'add');">
<input type="button" value="Update"
onClick="javasc ript:chgAction( 'update');">
</form>

As for your ASP syntax error, try putting that whole thing in one line
without breaking them up into two.
Bill S., on Wed, 05 Nov 2003 15:43:41 -0800, had to say:
Hi,

I am just starting to work with ASP, so bear that in mind...

I have an ASP page that displays records from a table, and
allows you to add, update and delete. There is a form with
one button that does adds and updates, and a second button
for deletes.

What I want to do is, instead of having the 'action' of the
form be something like:

action="updateU ser.asp?mode=up date"

I want to use the onClick property of Add/Update and Delete
buttons to set a value in a hidden field in the table, and NOT
have a query string, ie: action="updateU ser.asp"

The problem is that I have an 'If' statement to determine if
I need to do an add/update/delete or just display the records
and form:

If (Request.Form(" txtAction") = "update" Or
Request.Form("t xtAction") = "delete") Then

do some stuff...

End If

The problem is that when it runs, and the page is first
displayed, I get:

Error Type:
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/dms/updateUser.asp, line 49, column 43
If (Request.Form(" txtAction") = "update" Or
------------------------------------------^
This makes sense if you can't include a form field in
an If statement before the form has even been defined.
So I put an If statement before it to determine that case:

If Request.Form.Co unt > 0 Then
Is there a better way to do this? Is there something
obviously wrong with the If statement?

tia,
Bill


Jul 19 '05 #2
How about naming your two buttons the same?

<input type=Submit name=SubmitButt on value="Update">
<input type=Submit name=SubmitButt on value="Delete">

Then in your code....

<%
if Request.Form("S ubmitButton")=" Update" then
'Update
else
'probably Delete
end if

%>
"Bill S." <bi*********@ho tmail.com> wrote in message
news:74******** *************** ***@posting.goo gle.com...
Hi,

I am just starting to work with ASP, so bear that in mind...

I have an ASP page that displays records from a table, and
allows you to add, update and delete. There is a form with
one button that does adds and updates, and a second button
for deletes.

What I want to do is, instead of having the 'action' of the
form be something like:

action="updateU ser.asp?mode=up date"

I want to use the onClick property of Add/Update and Delete
buttons to set a value in a hidden field in the table, and NOT
have a query string, ie: action="updateU ser.asp"

The problem is that I have an 'If' statement to determine if
I need to do an add/update/delete or just display the records
and form:

If (Request.Form(" txtAction") = "update" Or
Request.Form("t xtAction") = "delete") Then

do some stuff...

End If

The problem is that when it runs, and the page is first
displayed, I get:

Error Type:
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/dms/updateUser.asp, line 49, column 43
If (Request.Form(" txtAction") = "update" Or
------------------------------------------^
This makes sense if you can't include a form field in
an If statement before the form has even been defined.
So I put an If statement before it to determine that case:

If Request.Form.Co unt > 0 Then
Is there a better way to do this? Is there something
obviously wrong with the If statement?

tia,
Bill

Jul 19 '05 #3

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

Similar topics

5
3432
by: ratlhead | last post by:
Hey all, I'm attempting to do some form processing on a server that has register_globals off, however, I've run into a confusing situation and need some help. Basically, the form is a multi-part/form-data form as I have it upload a file in addition to submit a number of other fields, but the error I have occurs even when no upload is...
7
6208
by: Shannon | last post by:
Hi everyone, I am trying to post some data to a form using the XMLHTTP object, and have run into a problem trying to find the proper location of the receiving page. The form points to a directory, like so: <form action="/servlet/Login" target="_top" method="POST" enctype="x-www-form-encoded" onSubmit='return goodform()'> but the...
2
3027
by: TanBrae | last post by:
Hi all. I found this forum while searching for an answer to an error message I am getting from my submission form on my website. I hope somebody will be able to help me with this. A bit of background: I have maintained my website (it's basically for the Labrador Retriever community) for several years through a wonderful host company. This...
8
4346
Megalog
by: Megalog | last post by:
Hey guys.. my turn to ask a question: I'm having a weird issue with a form I've reworked. This form has a combo box, which when used is changing the recordsource of a subform. This subform has no Master/Child relationship set to the main form. Specifically the problem seems to be that everytime the recordsource of the subform is changed, the...
2
1881
by: anusha.vempati9 | last post by:
Hi All, I am calling a cgi file from a perl module. The cgi file contains the HTML form and some HTML fields(like check boxes). In my logic, I am trying to submit the form and calling the same cgi file again. While doing this, i am not able to retain the values of the HTML fields (check boxes values ) which i set earlier before...
0
7897
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8190
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8331
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7940
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5705
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5379
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3824
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3850
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2336
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.