473,406 Members | 2,620 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,406 software developers and data experts.

Form Field/ Form Submit Problems (probably an easy answer...)

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 that has been
modified/clicked the form doesn't always submit. When it does work, a
Stored procedure is passed form variables and updates to the db are
made. When it doesn't, its as if the form wasn't submitted, it
reloads and resets the page, but the stored procedure isn't triggered.
Any help is greatly appreciated! Thanks..
Jul 19 '05 #1
4 4263
What makes you think it's not submitting? Code?

Ray at work

"Eric" <te******@yahoo.com> wrote in message
news:1a**************************@posting.google.c om...
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 that has been
modified/clicked the form doesn't always submit. When it does work, a
Stored procedure is passed form variables and updates to the db are
made. When it doesn't, its as if the form wasn't submitted, it
reloads and resets the page, but the stored procedure isn't triggered.
Any help is greatly appreciated! Thanks..

Jul 19 '05 #2
Perhaps if you showed your code, we would have a chance of assisting you.
As it is, I can only guess your problem is a condition branch that is
keeping your update code from
executing.
"Eric" <te******@yahoo.com> wrote in message
news:1a**************************@posting.google.c om...
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 that has been
modified/clicked the form doesn't always submit. When it does work, a
Stored procedure is passed form variables and updates to the db are
made. When it doesn't, its as if the form wasn't submitted, it
reloads and resets the page, but the stored procedure isn't triggered.
Any help is greatly appreciated! Thanks..

Jul 19 '05 #3
Thanks for the responses..

The reason why I don't think its submitting is because when I run SQL
profiler, on a normal Submit, I can see the stored procedure hit the db
and when it doesnt seem to work, the form looks like it submits but then
the SP never gets triggered(this happens about 2 out of three tries when
only the checkbox is changed). Honestly, I'm not actually sure that is
not submitting, just that its not firing off the SP unless one of the
text fields is modified.

I have cut and pasted the code below. Thanks again...

<!-- #INCLUDE FILE="hs.vbs" -->
'LOCAL

<%

session("mode")="update"

'add a record
IF Request.form("SubmitType")="add" then

'set edit mode
session("mode")="add"

'connect to the database
'on error resume next
set con = server.createobject("adodb.connection")
con.open application("connect") & session("database") & ";"
'insert new record
sql="spInsertContact "

for i=1 to 6
this="new"&i
sql=sql & "'" & trim(request.form(this)) & "',"
next

sql= sql & "'" & trim(request.form("new7")) &"'"
'execute
con.execute(sql)

'close ADO objects
'rs.close
con.close
'set rs = nothing
set con=nothing
sql=""
end if

'edit a record
if Request.form("SubmitType")="edit" then

'set edit mode
session("mode")="edit"

end if

'update a record
IF Request.form("SubmitType")="update" then

'set edit mode
session("mode")="update"
'connect to the database
'on error resume next
set con = server.createobject("adodb.connection")
con.open application("connect") & session("database") & ";"
SQL="spUpdateContact " & "'" & session("thisRecord") &"',"

for i=1 to 6
this="new"&i
sql=sql & "'" & trim(request.form(this)) & "',"
next

sql= sql & "'" & trim(request.form("new7")) &"',"
sql= sql & "'" & trim(request.form("new8")) &"'"

con.execute(sql)

'close ADO objects
con.close
set con=nothing
sql=""

end if

'delete a record
IF Request.form("SubmitType")="delete" then

'set edit mode
session("mode")="delete"

'connect to the database
'on error resume next
set con = server.createobject("adodb.connection")
con.open application("connect") & session("database") & ";"
SQL="spDelContact '" & session("thisRecord") &"'"

con.execute(sql)

'close ADO objects
con.close
set con=nothing
end if
IF Request.form("SubmitType")="cancel" then

'set edit mode
session("mode")="cancel"

end if
%>
<%

function setupForm()

dim htmlcode

if session("mode") ="edit" then

session("thisRecord")= request.form("contact")

'on error resume next
set con = server.createobject("adodb.connection")
con.open application("connect") & session("database") & ";"

htmlcode=htmlcode&"<table width='400' class='text'><tr>"

SQL=("spContactInfoEdit '" & session("thisRecord") &"'")

set rs = con.execute(SQL)
if not err.number=0 then
Response.Write "Error:"& err.Description
err.clear()
Response.End
end if

IF rs.eof = FALSE THEN
alldata= rs.getrows
numcols=ubound(alldata,1)
numrows=ubound(alldata,2)
htmlcode=htmlcode&"<td class='boldtext' style='text-align:left;'
width='120'>&nbsp;"&RS(0).name&" :</td>"
htmlcode=htmlcode&"<td width='150' class='text'><input type='text'
class='text' name='new1' value='" & alldata(0,0) &"'
maxlength='50'></td><tr>"

htmlcode=htmlcode&"<td class='boldtext' style='text-align:left;'
width='120'>&nbsp;"&RS(1).name&" :</td>"
htmlcode=htmlcode&"<td width='150' class='text'><select name='new2'>"

thischoice=fetchSQL("select [contact type],[contact type id] from
[contact list] order by [contact type id]")

for i=0 to ubound(thisChoice,2)
htmlcode=htmlcode & "<OPTION Value='"&thisChoice(1,i) &"'"

if alldata(1,0)=thisChoice(1,i) then
htmlcode=htmlcode&" SELECTED"
end if

htmlcode=htmlcode&" >"&thisChoice(0,i)&"</OPTION>"& vbcrlf
next

htmlcode=htmlcode&"</select> </td></tr>"& vbcrlf

htmlcode=htmlcode&"<td class='boldtext' style='text-align:left;'
width='120'>&nbsp;"&RS(2).name&" :</td>"
htmlcode=htmlcode&"<td width='150' class='text'><input type='text'
class='text' name='new3' value='" & alldata(2,0) &"'
maxlength='20'></td><tr>"

htmlcode=htmlcode&"<td class='boldtext' style='text-align:left;'
width='120'>&nbsp;"&RS(3).name&" :</td>"
htmlcode=htmlcode&"<td width='150' class='text'><input type='text'
class='text' name='new4' value='" & alldata(3,0) &"'
maxlength='20'></td><tr>"

htmlcode=htmlcode&"<td class='boldtext' style='text-align:left;'
width='120'>&nbsp;"&RS(4).name&" :</td>"
htmlcode=htmlcode&"<td width='150' class='text'><input type='text'
class='text' name='new5' value='" & alldata(4,0) &"'
maxlength='20'></td><tr>"

htmlcode=htmlcode&"<td class='boldtext' style='text-align:left;'
width='120'>&nbsp;"&RS(5).name&" :</td>"
htmlcode=htmlcode&"<td width='150' class='text'><input type='text'
class='text' name='new6' value='" & alldata(5,0) &"'
maxlength='20'></td><tr>"

htmlcode=htmlcode&"<td class='boldtext' style='text-align:left;'
width='120'>&nbsp;"&RS(6).name&" :</td>"
htmlcode=htmlcode&"<td width='150' class='text'><input type='text'
class='text' name='new7' value='" & alldata(6,0) &"'
maxlength='20'></td><tr>"

htmlcode=htmlcode&"<td class='boldtext' style='text-align:left;'
width='120'>&nbsp;"&RS(7).name&" :</td>"
htmlcode=htmlcode&"<td width='150' class='text'><input
type='checkbox' causesvalidation='true' name='new8' value='" &
alldata(7,0) & "'"

'check for checked value
if alldata(7,0)="*" then
htmlcode=htmlcode&" CHECKED"

end if
htmlcode=htmlcode&" onclick='toggle(8)'></td><tr>"

rs.close
con.close
set rs = nothing
set con = nothing

htmlcode=htmlcode&"<td colspan='2' align='center'>"
htmlcode=htmlcode&"<input type='button' value='Update' name='update'
onclick='updateRecord()' style='font: 8 pt Verdana, San-Serif;
background: white;'>&nbsp;"
'htmlcode=htmlcode&"<input type='button' value='Delete' name='delete'
onclick='deleteRecord()' style='font: 8 pt Verdana, San-Serif;
background: white;'>&nbsp"
htmlcode=htmlcode&"<input type='button' value='Cancel' name='cancel'
onclick='cancelIt()' style='font: 8 pt Verdana, San-Serif; background:
white;'>&nbsp"
htmlcode=htmlcode&"</td></tr>"
else

response.write "No data Returned"

end if

else

'setup table
htmlcode=htmlcode&"<table width='400' class='text'>"

'where [name]='" & session("thisServer") & "'")

'setup URL List

thisRS=fetchSQL("select distinct a.contact as 'Name', a.[contact id]
from [contact info] a join contacts b on b.[contact id]=a.[contact id]
join [contact list] c on a.[contact type] = c.[contact type id] join
[url list] d on d.[url id]=b.[url id] where b.[url id] in (select a.[url
id] from [url list] a where a.[url id] in ( select a.[url id] from urls
a join [Server info] b on b.[server id]=a.[server id] where b.name='" &
session("thisServer") & "'))")

htmlcode=htmlcode&"<tr><td width='150'><b>&nbsp;Contacts: </b></td><td
width='200' ><SELECT Name='Contact' onchange='editRecord()'> "
htmlcode=htmlcode & "<OPTION Value=''>--Choose Contact--</OPTION>"&
vbcrlf
for i=0 to ubound(thisRS,2)
htmlcode=htmlcode & "<OPTION Value="&thisRS(1,i)
htmlcode=htmlcode&">"&thisRS(0,i)&"</OPTION>"& vbcrlf
next
htmlcode=htmlcode&"</select></td></tr></table><br>"& vbcrlf
'setup input fields

htmlcode=htmlcode&"<table width='400'><tr><td class='boldtext'
style='text-align:left;' width='120'>&nbsp;Contact Name :</td>"
htmlcode=htmlcode&"<td width='150'><input type='text' class='text'
name='new1' value='' maxlength='20'></td></tr>"

htmlcode=htmlcode&"<td class='boldtext' style='text-align:left;'
width='120'>&nbsp;Contact Type :</td>"
htmlcode=htmlcode&"<td width='150' class='text'><select name='new2'>"

htmlcode=htmlcode&"<OPTION Value=''></OPTION>"& vbcrlf
'NOPE
thischoice=fetchSQL("select [contact type id],[contact type] from
[contact list] order by [contact type id]")
for i=0 to ubound(thisChoice,2)

htmlcode=htmlcode & "<OPTION Value='"&thisChoice(0,i)
htmlcode=htmlcode&"'>"&thisChoice(1,i)&"</OPTION>"& vbcrlf

next

htmlcode=htmlcode&"</select> </td></tr>"& vbcrlf

htmlcode=htmlcode&"<td class='boldtext' style='text-align:left;'
width='120'>&nbsp;Office Phone :</td>"
htmlcode=htmlcode&"<td width='150'><input type='text' class='text'
name='new3' value='' maxlength='20'></td></tr>"

htmlcode=htmlcode&"<td class='boldtext' style='text-align:left;'
width='120'>&nbsp;Cell Phone :</td>"
htmlcode=htmlcode&"<td width='150'><input type='text' class='text'
name='new4' value='' maxlength='20'></td></tr>"

htmlcode=htmlcode&"<td class='boldtext' style='text-align:left;'
width='120'>&nbsp;Home Phone :</td>"
htmlcode=htmlcode&"<td width='150'><input type='text' class='text'
name='new5' value='' maxlength='20'></td></tr>"

htmlcode=htmlcode&"<td class='boldtext' style='text-align:left;'
width='120'>&nbsp;Pager :</td>"
htmlcode=htmlcode&"<td width='150'><input type='text' class='text'
name='new6' value='' maxlength='20'></td></tr>"

htmlcode=htmlcode&"<td class='boldtext' style='text-align:left;'
width='120'>&nbsp;Email Address :</td>"
htmlcode=htmlcode&"<td width='150'><input type='text' class='text'
name='new7' value='' maxlength='50'></td></tr>"

'primary section

htmlcode=htmlcode&"<td class='boldtext' style='text-align:left;'
width='120'>&nbsp;Primary Contact?</td>"
htmlcode=htmlcode&"<td width='150' class='text'><input type='checkbox'
causesvalidation='true' name='new8' value='' "

'check for checked value
if new8="*" then
htmlcode=htmlcode&" CHECKED"

end if
htmlcode=htmlcode&" onclick='toggle(8)'></td></tr>"

'primary section
' add control buttons
htmlcode=htmlcode&"<td colspan='2' align='center'>"
htmlcode=htmlcode&"<input type='button' value=' Add ' name='add'
onclick='addRecord()' style='font: 8 pt Verdana, San-Serif; background:
white;'>&nbsp"
'htmlcode=htmlcode&"<input type='button' value=' Edit ' name='edit'
onclick='editRecord()' style='font: 8 pt Verdana, San-Serif; background:
white;'>&nbsp"
htmlcode=htmlcode&"<input type='button' value='Close' name='cancel2'
onclick='self.close()' style='font: 8 pt Verdana, San-Serif; background:
white;'>&nbsp"
htmlcode=htmlcode&"</td></tr>"

end if

set con = nothing
sql=""

'end table and form
htmlcode=htmlcode&"</table></form><br>"
response.write htmlcode
end function

%>

<html>
<head>
<title>Modify Contacts</title>
<link rel="stylesheet" href="hsdr.css">
<base target="main-bottom">


<script language="vbscript">

function addRecord()
'check for data
if NOT document.editcontacts.new1.value="" AND NOT
document.editcontacts.new2.value=""then

'check with the user
response=confirm("Add record?")

if response=true then
document.forms("editcontacts").SubmitType.value="a dd"
document.forms("editcontacts").submit()
end if
else
alert("Please fill-in required fields!")
end if

end function

function editRecord()

document.forms("editcontacts").SubmitType.value="e dit"
document.forms("editcontacts").submit()

end function

function deleteRecord()
'check with the user
response=confirm("Delete record?")

if response=true then

document.forms("editcontacts").SubmitType.value="d elete"
document.forms("editcontacts").submit()
end if

end function

function updateRecord()

'check with the user
response=confirm("Update record?")

if response=true then
document.forms("editcontacts").SubmitType.value="u pdate"
document.forms("editcontacts").Submit()
window.opener.location.reload()
window.close

end if

end function

function cancelIt()
document.forms("editcontacts").SubmitType.value="c ancel"
document.forms("editcontacts").submit()

end function

function toggle(this)

select case this

case 8

if document.editcontacts.new8.checked="false" then
document.editcontacts.new8.value="0"
else
document.editcontacts.new8.value="1"
end if

end select

end function

</script>

</head>

<body topmargin="0" leftmargin="5" >
<form name='editcontacts' action='editcontacts.asp' method='post'
target='_self'>
<input type='hidden' NAME='SubmitType' value=''>

<%=setupForm%>

<br>
</body>
</html>
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #4
You have all of your code in IFs. Maybe none of the conditions is true.
What does this do?

IF Request.form("SubmitType")="add" then
response.write "Submit time is add."
end if

if Request.form("SubmitType")="edit" then
response.write "Submit type is edit."
end if
IF Request.form("SubmitType")="update" then
response.write "Submit type is update."
end if

'delete a record
IF Request.form("SubmitType")="delete" then
response.write "Submit type is "delete."
end if
IF Request.form("SubmitType")="cancel" then
response.write "Submit type is cancel."
end if
Ray at work
Jul 19 '05 #5

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

Similar topics

2
by: www | last post by:
Hi there, I' m getting a (0x80040E2F) error, if I submit my form, with blank textboxes to my update stored procedure. The stored procedure expect values, so how can I detect if a form field was...
6
by: malcolm | last post by:
How does one get the primary key of the row that is joined in via a group by aggregate clause when the aggregate is not performed on the primary key? For example, Person table ( PersonID...
1
by: Steve Darby | last post by:
Hi there, I wonde if anyone can help me. I have a couple of problems which I am having trouble resolving. Firstly, I have written a form which includes field for First Name, Surname and...
3
by: Bob | last post by:
I'm a total newbie at Javascript, but a programmer for over 20 years... so, my plans may be bigger than they are possible. I'm trying to set with Javascript the value of a form field... easy...
6
by: Joop | last post by:
Hi all, I'm kinda new to JavaScript, but hey... I'm trying anyway! ;-) So, here's my problem : I've created a table in my document, presenting a list of items, one can 'select' by clicking...
3
by: ed_spain | last post by:
Hi Everyone, On an HTML page with 2x different forms, how can I redisplay the same page after a submit, restoring the values from BOTH forms even though only one was submitted? I have an...
3
by: Rob Meade | last post by:
Hi all, I have a login page which has username and password fields, a login button, and 2 validation controls (one for each field) - currently I have controls to display to the summary if the...
2
by: bravesplace | last post by:
I have a form field on an ASP page and was wondering if I can require the number that is entered to begin with a 0 or a 2. If the number starts with anything else, the user is notified to update...
6
by: millw0rm | last post by:
i got a form full of radio buttons appx. 60-70, depends on the page. Some times 60, sometimes 55.... After certain period of time, i want to disable or make readonly all the radio button inside the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...

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.