Ask a Question related to ASP, Design and Development.
-
Eric #1
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..
Eric Guest
-
Autopopulated form not displaying data in pdfunless the form field is clicked
Within my online application, I have a pdf form that is auto generated and displayed to the user in the browser. My problem is that the populated... -
required field vs disabled submit button.in a form
I'm trying to make my email field required. Have seen and tried multiple solutions from this forum, with no success. I think it has something to... -
copy and paste form RTF document into field in asp form cause it to bypass field length and javascript validation - how to overcome?
I have a web form with several fields. If I copy & paste from a RTF document into a field, the javascript validation and field length are bypassed... -
Form verification and creating a hidden field on submit
Hi All, I have a form that has a number of radio boxes and input fields for the user to select from. The form is part of a survey. The problem is... -
form field submit order
Hello, Not sure if this is an asp or dreamweaver or a.n.other editor problem... I have a form with stacks of fields. This is submitted to a... -
Ray at #2
Re: Form Field/ Form Submit Problems (probably an easy answer...)
What makes you think it's not submitting? Code?
Ray at work
"Eric" <tek_1975@yahoo.com> wrote in message
news:1ad224de.0309230920.5080ccb4@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..
Ray at Guest
-
Tom B #3
Re: Form Field/ Form Submit Problems (probably an easy answer...)
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" <tek_1975@yahoo.com> wrote in message
news:1ad224de.0309230920.5080ccb4@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..
Tom B Guest
-
Eric P #4
Re: Form Field/ Form Submit Problems (probably an easy answer...)
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'> "&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'> "&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'> "&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'> "&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'> "&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'> "&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'> "&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'> "&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;'> "
'htmlcode=htmlcode&"<input type='button' value='Delete' name='delete'
onclick='deleteRecord()' style='font: 8 pt Verdana, San-Serif;
background: white;'> "
htmlcode=htmlcode&"<input type='button' value='Cancel' name='cancel'
onclick='cancelIt()' style='font: 8 pt Verdana, San-Serif; background:
white;'> "
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> 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'> 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'> 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'> 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'> 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'> 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'> 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'> 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'> 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;'> "
'htmlcode=htmlcode&"<input type='button' value=' Edit ' name='edit'
onclick='editRecord()' style='font: 8 pt Verdana, San-Serif; background:
white;'> "
htmlcode=htmlcode&"<input type='button' value='Close' name='cancel2'
onclick='self.close()' style='font: 8 pt Verdana, San-Serif; background:
white;'> "
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!
Eric P Guest
-
Ray at #5
Re: Form Field/ Form Submit Problems (probably an easy answer...)
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
Ray at Guest



Reply With Quote

