|
-
Jul 16th, 2004, 05:01 AM
#1
Thread Starter
Junior Member
Basic question (SOLVED) Thanks!
I use this structure when updating or inserting stuff to the database. I've got a problem with it though when I tell them "no good input" all previous input is lost. I tried adding some asp(vb) to the javascript controle function, but I don'tknow how to add the conclusion(True /False) that I have in asp to the Javascript function return.
<!--#include file="include/connect.asp"-->
<% Call CheckSession()
If Request.Form("add") = "1" then
{check something out of database (like if the reccord doesn't already exist.)}
{if ok do database change}
{else tell them not good}
end if
%>
<html>
<head>{blablabla}
<SCRIPT LANGUAGE="JavaScript">
function controle()
{
[check something]
}
</head>
<BODY {blablabla}>
<form name="form" method="post" action="UpdateAccount.asp?aid=<%=Request.QueryString("aid")%>">
<input type="hidden" name="add" value="1">
{input stuff}
<input type="button" name"update" value="Update" onClick="onClick="if (controle()) parent.body.form.submit">
</form>
</body>
</html>
How do you guys do that?
Thanks
Last edited by ShotokanTuning; Jul 19th, 2004 at 05:48 AM.
-
Jul 16th, 2004, 08:25 AM
#2
Once you submit a form, all its value are reset, you have to manually re-fill them.
e.g
in your {input stuff} section
<input type=textbox name=FirstName value="<%Request.form("FirstName")%>">
Thougn ASP.net tackles this issue by allowing developer to retain the state if they wish.
Hope this helps.
Danial
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jul 16th, 2004, 09:04 AM
#3
Thread Starter
Junior Member
Originally posted by Danial
Once you submit a form, all its value are reset, you have to manually re-fill them.
Yeah I know that's why I tried to add some ASP(vb) to the Javascript function. If I'd know how to...
Hope this helps.
Danial [/B]
Yeah this, but only for new stuff, since when you load it the first time it's empty anyway.
But while updating that's not always so, some are but others aren't, making it unusable.
Example user wants to update a Visit Report. Get on the update page, the old values are shown. He updates some, then he clicks the update button. The javascript functions returns true. Form Submit. Then a check if the updates do not make this VisitReport overide another Visit Report (not the one being updated of course). Turns out it would overide one. So message don't do that. Now there is a problem you can't give do this: value=(work in progress value) because they already have the (old value).
I could send all the data to a new page and put the value=(work in progress data) there. But there must be a better way.
There is another problem that happens with your solution, the problem I described at the pre-insert data into input type=file topic.
Thanx anyway Danial, it does fix a part of the problem.
-
Jul 16th, 2004, 09:11 AM
#4
I dont understand what you are trying to say. I dont see any problem even if you are updating existing data. I assume you are trying to retain what the user typed in (modified) and re-display them in case the Update was not sucessfull/denied. In that case it would still work.
Have i got it wrong? If you clarify more i could probably explain further.
Danial
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jul 16th, 2004, 09:42 AM
#5
Thread Starter
Junior Member
Let's asume this example when displaying page:
Accountname: <input type="text" name="accountname" value="<%=rsAccount("CompanyName")%>">
While you want to do this if submitted and found to be invalid data:
Accountname: <input type="text" name="accountname" value="<%=Request.form("accountname")%>">
Only way to do that is submit a different page.
I hope this explaned it better.
-
Jul 16th, 2004, 10:29 AM
#6
Originally posted by ShotokanTuning
Let's asume this example when displaying page:
Accountname: <input type="text" name="accountname" value="<%=rsAccount("CompanyName")%>">
While you want to do this if submitted and found to be invalid data:
Accountname: <input type="text" name="accountname" value="<%=Request.form("accountname")%>">
Only way to do that is submit a different page.
I hope this explaned it better.
Well in that case use a hidden value to determine whether the action is Loading 1st time or its the 2nd load.
e.g
<%
dim AccountName
if action ="edit" then
AccountName = rsAccount("CompanyName")
else
AccountName = Request.form("accountname")
end if
%>
<input type="text" name="accountname" value="<%=AccountName%>">
That should solve the problem..
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Jul 19th, 2004, 05:48 AM
#7
Thread Starter
Junior Member
Now that's cool coding.
Works great.
Thank you Danial.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|