473,387 Members | 3,821 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,387 software developers and data experts.

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="updateUser.asp?mode=update"

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="updateUser.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("txtAction") = "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.Count > 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 3402
This is one way of changing the form action using javascript:

<script language="JavaScript">
// Changes the form txtAction variable and submits the form
function chgAction(m_action){
document.formname.txtAction = m_action;
document.formname.submit();
}
</script>

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

blah-blah

<input type="button" value="Add"
onClick="javascript:chgAction('add');">
<input type="button" value="Update"
onClick="javascript: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="updateUser.asp?mode=update"

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="updateUser.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("txtAction") = "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.Count > 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=SubmitButton value="Update">
<input type=Submit name=SubmitButton value="Delete">

Then in your code....

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

%>
"Bill S." <bi*********@hotmail.com> wrote in message
news:74**************************@posting.google.c om...
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="updateUser.asp?mode=update"

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="updateUser.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("txtAction") = "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.Count > 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
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...
7
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...
2
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...
8
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...
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.