Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirecting to itself help?

Status
Not open for further replies.

croiva25

Technical User
Dec 3, 2003
125
0
0
AU
HI guys, by reading posts in this forum I have changed my web page so when users submit the data the page doesn't get redirected but it submits to itself, so visibly it clear the values and submits and they are happy as that speeds up the process but what I haven't relized up until now is that because the INSERT query is part of the code on the same page the INSERT is happening every time the page is refreshed or every time the page is accessed/loaded and I get these NULL values.

I mean that is not such a huge problem at the moment, I can see which records where the result of loading/refershing the page and which ones are true submissions but I am thinking it shouldn't be this way.

Can this be done so it doesn't insert null records, how can I change the page so it visibly works the same way but doens't insert nulls.

Hope somebody can help.Thanks
 
Use an if/then statement to see whether the page is being posted and, if so, then do your insert statement, else just reload the page. Easy way is to just check to see if the submit button (presuming that's what you're using) is there and, if so, then run your insert command.
Code:
<% [COLOR=green]'Put this near the top of your page so it is the first thing to look for.[/color]
if len(request.form("btnSubmit")) then [COLOR=green]'this tests to see if the user clicked on the submit button to get to this page.[/color]
  'do your insert now.
end if
%>

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
Ok but my button is an inserted image,I don't have then name for it?


<td align="right" width="557"> <a href="javascript: SaveDetails()"><img src="images/Submit_0001.jpg" width="75" height="30" border="0">

Thanks for your help
 
Don't really deal with images on a normal basis, so not sure how to best answer that issue. Another alternative would be to set a hidden variable in your form and then test for it. Same process as my first post, just a different variable to test for.

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
Sorry to bother you with this again, but this doesn't work. I will post all of my code and maybe you can help me.

So this is my Insert code

Call myCon.Execute("INSERT INTO BloodInventory (ProductID, locations, RBC,PhenotypeReserve, CMV, IRR, AverageDailyIssues, " & _
"DaysRemaining, SDLPF, TWLPF, FilteredApheresis, UserName,Scan, address, FilteredPaediatric, TimeEntered) VALUES (" & _
BuildString(unescape(Request.QueryString("ProductID").Item)) & ", " & _
BuildString(unescape(Request.QueryString("locations").Item)) & ", " & _
BuildString(unescape(Request.QueryString("RBC").Item)) & ", " & _
BuildString(unescape(Request.QueryString("PhenotypeReserve").Item)) & ", " & _
BuildString(unescape(Request.QueryString("CMV").Item)) & ", " & _
BuildString(unescape(Request.QueryString("IRR").Item)) & ", " & _
BuildString(unescape(Request.QueryString("AverageDailyIssues").Item)) & ", " & _
BuildString(unescape(Request.QueryString("DaysRemaining").Item)) & ", " & _
BuildString(unescape(Request.QueryString("SDLPF").Item)) & ", " & _
BuildString(unescape(Request.QueryString("TWLPF").Item)) & ", " & _
BuildString(unescape(Request.QueryString("FilteredApheresis").Item)) & ", " & _
BuildString(Request.Cookies("Login").Item) & ", " & _
BuildString(unescape(Request.QueryString("Scan").Item)) & ", " & _
BuildString(unescape(Request.QueryString("address").Item)) & ", " & _
BuildString(unescape(Request.QueryString("FilteredPaediatric").Item)) & ", GetDate())")

Call myCon.Close


and this is my button

<INPUT type="Submit" name="Submit" value=" Submit " language=javascript onclick="SaveDetails()">[/color red]

YOur suggestion will insert null records when the page loads and none when I actually try to submit.






 
Are you receiving a specific error message? How are you calling your INSERT statement? What is the "SaveDetails()" function? Do you not have a server-side conditional that will check to see if the page is actually being submitted? It would help to know these things in order to determine where the problem actually is.

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
Well that is the thing, we seem to do things slightly different and then when somebody helps me I sometimes find it hard to "translate" that into a way I can use it myself.

I have no error,the insert just doesn't occur. All I was doing is

If len(Request.Form("Submit") then
Call myCon.Execute("INSERT INTO BloodInventory (ProductID, locations, RBC,PhenotypeReserve, CMV, IRR, AverageDailyIssues, " & _
"DaysRemaining, SDLPF, TWLPF, FilteredApheresis, UserName,Scan, address, FilteredPaediatric, TimeEntered) VALUES (" & _
BuildString(unescape(Request.QueryString("ProductID").Item)) & ", " & _
BuildString(unescape(Request.QueryString("locations").Item)) & ", " & _
BuildString(unescape(Request.QueryString("RBC").Item)) & ", " & _
BuildString(unescape(Request.QueryString("PhenotypeReserve").Item)) & ", " & _
BuildString(unescape(Request.QueryString("CMV").Item)) & ", " & _
BuildString(unescape(Request.QueryString("IRR").Item)) & ", " & _
BuildString(unescape(Request.QueryString("AverageDailyIssues").Item)) & ", " & _
BuildString(unescape(Request.QueryString("DaysRemaining").Item)) & ", " & _
BuildString(unescape(Request.QueryString("SDLPF").Item)) & ", " & _
BuildString(unescape(Request.QueryString("TWLPF").Item)) & ", " & _
BuildString(unescape(Request.QueryString("FilteredApheresis").Item)) & ", " & _
BuildString(Request.Cookies("Login").Item) & ", " & _
BuildString(unescape(Request.QueryString("Scan").Item)) & ", " & _
BuildString(unescape(Request.QueryString("address").Item)) & ", " & _
BuildString(unescape(Request.QueryString("FilteredPaediatric").Item)) & ", GetDate())")

Call myCon.Close
end if


but I am not sure if I am using this code properly,that is why I thought if I posted all my code that maybe you can see where has my attempt gone wrong.

SaveFunction() is the javascript funtion that checks/validates enteries and 'builds' everything for the insert query.

I don't have anything checking if the page has been submitted, if I am understanding you correctly.

Thanks



 
Ok, maybe I'm tired and missing something but your code looks ok (outside of what I think is a typo). Fix this:
Code:
If len(Request.Form("Submit")[COLOR=red])[/color] then
Which now makes me wonder how you are submitting. Are you using POST or GET when you submit your page? Since you're using querystring variables, I suspect that maybe you are using GET. Can you post how you are creating your form, what the action and method is?

Or, if you are not using a form (which is something that just occurred to me), then when doing your check, just check Request("submit"). Or pass your Submit via querystring and check for it there.

------------------------------------------------------------------------------------------------------------------------
If you don't have a sense of humor, you probably don't have any sense at all.
- Anonymous
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top