Updating field information

Results 1 to 2 of 2

Thread: Updating field information

  1. #1
    d huber Guest

    Default Updating field information

    I am working with someone else&#039s code. (It&#039s extensive. I can post it if it helps clarify my question.)<BR><BR>I am updating table records through an ASP page.<BR><BR>One line of code is <BR>&#060;form method="POST" action="AddPosition.asp"&#062;<BR><BR>AddPosition. asp is the name of the file that I am working in. So the code is sending the page back to itself.<BR><BR>I can split the code out into a second page, and it makes reasonable sense to me, however, I would like to understand what happens when a page posts back to itself.<BR><BR>Does anyone know of a resource that explains this approach to coding pages? <BR><BR>thanks,<BR>d

  2. #2
    Join Date
    Dec 1969

    Default Reposting to same page...

    I write code that posts back to myself all the time!<BR><BR>And when, for example, you are writing a "page through the table" display, it&#039s really the *only* way to write code.<BR><BR>In this case, based on the name you mentioned--AddPosition.asp--I&#039d guess that this page adds something to a database (a "position"--a job posting or something like that?). And I&#039d bet that, after doing the add, it gives the user a chance to repeat the operation.<BR><BR>Am I right?<BR><BR>So the "trick" to this page will be that, somewhere near the *logical* top of the code (that is, ignoring subroutines, etc., that are placed before the mainline stuff), you will have an "IF" that passes control *around* the database "add position" operations the first time the user hits this page.<BR><BR>That is, the logic will look something like this:<BR><BR>********************<BR>IF there is a position to be posted THEN<BR> &nbsp; &nbsp; Add the position to the database<BR>END IF<BR>Create the "Add Position" Form for the user<BR>********************<BR><BR>In short, there is absolutely nothing whatsoever special about posting back to the same page. If you need to distinguish between first-time-on-page and reposted-to-same-page, then just make sure you have something in the form (or query string) that you can use to distinguish one from the other.<BR><BR>So look for the form fields on the page. Then look at the "top" of the code and see if you don&#039t see a test for a value that is coming from one of those form fields. Presumably, when you come from some other page that value won&#039t appear. Presto.<BR><BR>Okay?<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts