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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Disappearing

Status
Not open for further replies.

JohannIcon

Programmer
Sep 3, 2002
440
MT
Dear All,

I have a problem which I cannot solve. Let me tell you my situation.

I have a normal entry form, where the user can enter a news article. So I have the Title, Category (list-box to choose from), Date and text of the article. That I can update easily. However the problem is that I have given the option to the user to create a new category from this form, and if he does so, then I refresh the page to get the new value of the category (the user entered). But my problem is that since I refresh the page, the details that the user has entered in the other fields, since they are not saved, are lost and he has to enter them again. Is there a way round this problem?

Thanks for your help and time
 
Why refresh the page? Give the option to add new category, get all the other information, submit the page. Then on the next page if a new category has been added then add it to the db THEN add the information into that new category.

 
Yes that is what I am doing now. I have added a new textbox so that if the user wants to add a new category, then he just enters it in the textbox and i process the results.

Thanks for your help!
 
how are you refreshing the page ?

response.redirect "mypage.asp?formitem1=blah&formitem2=blah1"

then pick up the values using request.querystring

 
a traditional way of preserving data between forms, is to loop through the received form fields on the receiving page, and put that existing data into "hidden" form inputs in the new form on that page, as such:

<form method=&quot;post&quot;>
<%
Dim x
For each x in Request.Form
Response.Write &quot;<input type=&quot;&quot;hidden&quot;&quot; name=&quot;&quot;&quot; & x & &quot;&quot;&quot; value=&quot;&quot;&quot; & Request.Form(x) & &quot;&quot;&quot;>&quot;
Next
%>
... rest of form ...
</form>


(note about word-wrapping, that the Response.Write line needs to be all on one line. also note if your Request.Form(x) value has any quotes in it, you'll want to replace them with the HTML-encoded value &amp;quot; so as not to mess up the hidden input.)

If this is not the problem you are encountering, please reply with more specifics.

best of luck!
-f!
 
Yes I know that I can pass them as a querystring or else as hidden vars, but what if I have 50 fields and 10 of them are textboxes? Then the querysting is very long and to pass them as hidden vars, it would be take a long process.

I solved it by adding an extra textfield.

Thanks for all your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top