Auto-submit hidden form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #16
    How else are you using this page? In other words, when you access this page, you obviously want it to set a value in the database, so you have tried submitting a form. What behaviour do you require on this page? Would it ever be that when you access this page, you don't want to set that value?

    Comment

    • golddigger50
      New Member
      • Mar 2007
      • 10

      #17
      The server behavior, would be to update the record in the database and I would like to update record everytime user accesses this page. Hope this was helpful...




      Originally posted by acoder
      How else are you using this page? In other words, when you access this page, you obviously want it to set a value in the database, so you have tried submitting a form. What behaviour do you require on this page? Would it ever be that when you access this page, you don't want to set that value?

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #18
        By updating, you mean setting confirmed to true/yes/1?

        Try this:
        Code:
        <cfquery datasource="website_users">
          UPDATE #ExpandPath ("/Mailbox\Database\website_users.mail")# SET Confirmed=1
          WHERE ID=#Recordset1.ID# 
        </cfquery>
        Last edited by acoder; Apr 2 '12, 01:03 PM.

        Comment

        • golddigger50
          New Member
          • Mar 2007
          • 10

          #19
          This code seems like it should work but I am not getting the record to update to a true value.
          Last edited by acoder; Apr 2 '12, 01:04 PM.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #20
            The Recordset1 query should be before this update query.

            Comment

            • golddigger50
              New Member
              • Mar 2007
              • 10

              #21
              Acoder,

              Thank you for your time and your help. This is the code that worked.


              Code:
              <cfquery name="Recordset1" datasource="website_users">
              SELECT * FROM #ExpandPath ("/Mailbox\Database\website_users.mail")# WHERE UserID = #Session.MM_UserID# 
              ORDER BY ID DESC 
              </cfquery>
               <cfquery datasource="website_users">
                UPDATE #ExpandPath ("/Mailbox\Database\website_users.mail")# SET Confirmed=1
                WHERE ID=#Recordset1.ID# 
                </cfquery>
              I was getting errors because I had not deleted the form. After I removed the form there were no errors but the value was not being inserted. I then realized that the <cfif> isdefined ....updateform. .. that is inserted when dreamweaver updaterecord server behavior is used had not been removed. I removed it and it worked great. I could not have done it without your help Thanks.

              Golddigger

              Originally posted by acoder
              The Recordset1 query should be before this update query.
              Last edited by acoder; Apr 2 '12, 01:03 PM.

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #22
                No problem. You're welcome. Glad you got it working.

                Comment

                • tazosmr
                  New Member
                  • Feb 2012
                  • 4

                  #23
                  Here is a working auto-submit method: when page is loaded, it will the form will be immediately autosubmited (the values can be set with php variables).
                  Code:
                  <form action="page.php"  method="post">
                  <input type="text" name="example1" value="<?php echo $_POST['something1'];?>" />
                  <input type="text" name="example2" value="ANOTHER_YOUR_VALUE" />
                  <input type="submit" />
                  </form>
                  
                  <SCRIPT LANGUAGE="JavaScript">document.forms[0].submit();</SCRIPT>
                  for example, the $_POST['something1'] value is received from the previous real-user submited Form, and this form can add another input with ANOTHER_YOUR_VA LUE.

                  _______________ ________
                  Last edited by acoder; Jan 26 '13, 09:53 PM. Reason: Removed bold tags

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #24
                    ...except that the question was Coldfusion-related :)

                    Just a note that the script language attribute is deprecated - use, for example,
                    Code:
                    <script type="text/javascript">

                    Comment

                    Working...