7 Replies Latest reply on Jul 18, 2008 7:48 AM by (Nick_Jewett)

    Insert Record Link - Instead of Insert Record Form

      Is there a way to within a repeating table, have a column with an "add record" link. Instead of this link taking you to a "Insert Record Form Page" populated with the record to be added, can the "add record" link immediately add the record without sending you to another page with the add record form.

      If this is not possible, is there a way to add a "onload submit form" behavior to the "Insert Record Form Page" so the form submits as soon as it is populated and the user does not see the form page.

      Curious if there is an easier way to accomplish this within the Interakt/ADDT package of behaviors?

        • 1. Re: Insert Record Link - Instead of Insert Record Form
          Günter Schenk Level 4

          making any ADDT form perform such an "onload submit" action is quite easy to do:

          1. build your form the way you´d usually do

          2. double-click the "Insert"- or "Update" Transaction entry in the Server Behaviour panel

          3. let´s take a look at the "select transaction starter event" section in the Server Behaviour´s "Basic" tab -- after a form has been created, you´ll always see the default values:

          First check variable: Form Variable :: "KT_Update1" (the name of the submit button)

          Now this is what can be easily changed to a different "starter event" condition. Let´s assume you´re adding the variable "auto_insert=Y" to your "add record" link :: now change the default "starter" to:

          First check variable: URL parameter :: "auto_insert" This will be checking if this variable has been set, and if so, trigger the transaction.

          You could even allow the transaction to be triggered without any "remote command", means when the page loads ::

          First check variable: Entered Value :: "1" (or whatever else)

          Hope this helps !

          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: Insert Record Link - Instead of Insert Record Form
            Level 1
            Thanks for the quick response.

            I tried both methods described, and they both attempt to submit the form onload as needed. However, they submit the form before the form is populated with the data coming from the previous page. As a result I get the following error:

            SQL error: Column 'userId' cannot be null."

            "userId" is one of the form fields that is required in the form.

            Is there a way to set the submit to happen after the form is populated.

            Thanks again for your help.
            • 3. Re: Insert Record Link - Instead of Insert Record Form
              Günter Schenk Level 4

              "populated" with what info ? However, it´s possible to define an "initial" value for each form field in DW´s Inspector, and if that data is getting passed from an URL parameter as well, you can choose that there.

              Günter Schenk
              Adobe Community Expert, Dreamweaver
              • 4. Re: Insert Record Link - Instead of Insert Record Form
                I changed the submit button to a standard button and am calling a local javascript function with onclick() to do some processing before submitting the form.

                At the end of the local function I do a form.submit();. From what I can tell, the insert transaction isn't getting triggered. Do you have a suggestion?

                • 5. Re: Insert Record Link - Instead of Insert Record Form
                  Günter Schenk Level 4
                  Hi Stuart,

                  From what I can tell, the insert transaction isn't getting triggered. Do you have a suggestion?

                  ADDT by default checks for a form element carrying a certain "name" attribute, e.g. the Update Record form´s Submit button will have the name "KT_Update1" -- which is BTW something you can change at a later time by double-clicking the "Update Transaction" entry in DW´s Server Behaviours panel and modifying stuff in the "select transaction starter event" category, e.g. by replacing the default "KT_Update1" entry with whatever name of whatever additional button you provide

                  In your case I reckon that you´d simply need to assign this name to your standard button -- though I don´t know if you wouldn´t actually need a regular Submit button to process the form elements correctly.

                  Günter Schenk
                  Adobe Community Expert, Dreamweaver
                  • 6. Re: Insert Record Link - Instead of Insert Record Form
                    Level 1
                    I have it working now. Your messages here got me on the right track. Thanks!

                    I actually changed the trigger to watch one of the hidden fields I'm updating in the local function. It seems to have done the trick.

                    Thanks again.

                    • 7. Re: Insert Record Link - Instead of Insert Record Form
                      I've not had any luck setting the "select transaction starter event" First check variable. to a field ID. <br /> <br />My update form is populated by a record set which walks the database resets a field and sends an email which is customized by the recordset. The update form works great but I can't get it to submit onload. I'm missing some piece to the puzzle.. nick <br /> <br />here is the page: <br /> <br /><?php require_once('Connections/conn_catboats.php'); ?> <br /><?php<br />// Load the common classes<br />require_once('includes/common/KT_common.php');<br /><br />// Load the tNG classes<br />require_once('includes/tng/tNG.inc.php');<br /><br />// Make a transaction dispatcher instance<br />$tNGs = new tNG_dispatcher("");<br /><br />// Make unified connection variable<br />$conn_conn_catboats = new KT_connection($conn_catboats, $database_conn_catboats);<br /><br />// Start trigger<br />$formValidation = new tNG_FormValidation();<br />$formValidation->addField("EMail", true, "text", "email", "", "", "");<br />$tNGs->prepareValidation($formValidation);<br />// End trigger<br /><br />//start Trigger_SendEmail trigger<br />//remove this line if you want to edit the code by hand<br />function Trigger_SendEmail(&$tNG) {<br />  $emailObj = new tNG_Email($tNG);<br />  $emailObj->setFrom("Catboats@Whispercom.com");<br />  $emailObj->setTo("{rsLive.EMail}");<br />  $emailObj->setCC("");<br />  $emailObj->setBCC("");<br />  $emailObj->setSubject("Catboats Web Site - {LNAME}");<br />  //WriteContent method<br />  $emailObj->setContent("Dear {rsLive.FN_MI} {rsLive.LNAME},<br />  <br /><p>After a year of study, development and testing, we are (finally) nearing the dawn of the new CBA web site.  We are pleased to announce that the new web site will go live within the next week.  It presents a slick new portal to the world of catboating.  We have attempted to bring over all that the old site contained, adding new features, while fixing that which was broken.  The old web site will live on for a short period of time, but will soon go off the air.<br /><br />Please be patient - the volunteers who have been hard at work are just that - volunteers.  We would appreciate any and all feedback (the good, the bad, the ugly, the wish list) and we will attempt to fix the non-operational items as well as extend the capabilities of the site in the coming months and years.<br /><br />Some of the new features of the site will be accessible to members only, requiring a username and password.  These items are listed below and will be usable from day one.  We have provided this mass emailing to those members who have shared their email addresses with us.</p><p>To use the new discussion board and Cats For Sale sections of the web site you will need to click the LOGIN link, on the left-hand menu and login as a member, most likely you are in the Cat Boat Association database in which case you shouldn't register as a new member. Instead login using the \"Username and Password\" provided below. </p><P>After you login you will see another item added to the menu on the left titled \"MEMBERS ONLY\"! Click it and view a page where you can search for members, update your personal information and most importantly change your username and password to something more convenient. The username must be unique, like your email address.<p></p><P></P>Your temporary username and password are:</P><P><strong>Username: {rsLive.username_usr}</strong></P> <P><strong>Password: {rsLive.password_usr} </strong></P><P><a href=\"\">Catboats.org</a></P><P>Don't hesitate to call if you have difficulty, 360-271-8659 or email me at <a href=\"mailto:Catboats@whispercom.com\">Catboats@whispercom.com</a> (be sure and put the word \"Catboats\" as the first word on the subject line!<P></p><P>Thanks for your patience while we get the new site working smoothly,<P></P><P>Happy Sailing,</P><P>Tim Lund, CBA<br />  Nick Jewett,Whispercom.com</P>");<br />  $emailObj->setEncoding("ISO-8859-1");<br />  $emailObj->setFormat("HTML/Text");<br />  $emailObj->setImportance("Normal");<br />  return $emailObj->Execute();<br />}<br />//end Trigger_SendEmail trigger<br /><br />if (!function_exists("GetSQLValueString")) {<br />function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") <br />{<br />  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;<br /><br />  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);<br /><br />  switch ($theType) {<br />    case "text":<br />      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />      break;    <br />    case "long":<br />    case "int":<br />      $theValue = ($theValue != "") ? intval($theValue) : "NULL";<br />      break;<br />    case "double":<br />      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";<br />      break;<br />    case "date":<br />      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br />      break;<br />    case "defined":<br />      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;<br />      break;<br />  }<br />  return $theValue;<br />}<br />}<br /><br />mysql_select_db($database_conn_catboats, $conn_catboats);<br />$query_rsLive = "SELECT CBA_ID, username_usr, password_usr, LNAME, FN_MI, EMail, sent_live FROM CBA WHERE EMail LIKE '%@%' AND FN_MI='nick' AND  sent_live=1 ORDER BY CBA_ID";<br />$rsLive = mysql_query($query_rsLive, $conn_catboats) or die(mysql_error());<br />$row_rsLive = mysql_fetch_assoc($rsLive);<br />$totalRows_rsLive = mysql_num_rows($rsLive);<br /><br />// Make an update transaction instance<br />$upd_CBA = new tNG_update($conn_conn_catboats);<br />$tNGs->addTransaction($upd_CBA);<br />// Register triggers<br />$upd_CBA->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "EMail");<br />$upd_CBA->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);<br />$upd_CBA->registerTrigger("AFTER", "Trigger_SendEmail", 98);<br />$upd_CBA->registerTrigger("END", "Trigger_Default_Redirect", 99, "live100.php");<br />// Add columns<br />$upd_CBA->setTable("CBA");<br />$upd_CBA->addColumn("sent_live", "NUMERIC_TYPE", "POST", "sent_live");<br />$upd_CBA->addColumn("CBA_ID", "NUMERIC_TYPE", "CURRVAL", "CBA_ID");<br />$upd_CBA->addColumn("LNAME", "STRING_TYPE", "POST", "LNAME");<br />$upd_CBA->addColumn("FN_MI", "STRING_TYPE", "POST", "FN_MI");<br />$upd_CBA->addColumn("EMail", "STRING_TYPE", "POST", "EMail");<br />$upd_CBA->setPrimaryKey("CBA_ID", "NUMERIC_TYPE", "POST", "CBA_ID");<br /><br />// Execute all the registered transactions<br />$tNGs->executeTransactions();<br /><br />// Get the transaction recordset<br />$rsCBA = $tNGs->getRecordset("CBA");<br />$row_rsCBA = mysql_fetch_assoc($rsCBA);<br />$totalRows_rsCBA = mysql_num_rows($rsCBA);<br />?> <br /> <br /> <br /> <br /> <br /> <br /> <script src="includes/common/js/base.js" type="text/javascript"></script> <br /> <script src="includes/common/js/utility.js" type="text/javascript"></script> <br /> <script src="includes/skins/style.js" type="text/javascript"></script> <br /><?php echo $tNGs->displayValidationRules();?> <br /> <br /> <br /> <br /><?php<br /> echo $tNGs->getErrorMsg();<br />?> <br /><?php echo $row_rsLive['CBA_ID']; ?> <a href="">Catboats.org</a> <br /> <form method="post" id="form1" action="%3C?php%20echo%20KT_escapeAttribute(KT_getFullUri());%20?%3E"> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <table cellpadding="2" cellspacing="0" class="KT_tngtable"> <tr> <td class="KT_th"> <label for="sent_live">Sent_live:</label> </td> <td> <input type="text" name="sent_live" id="sent_live" value="2" size="32" /> <br /> <?php echo $tNGs->displayFieldHint("sent_live");?> <?php echo $tNGs->displayFieldError("CBA", "sent_live"); ?></td> </tr> <tr> <td class="KT_th"> <label for="CBA_ID">CBA_ID:</label> </td> <td> <input type="text" name="CBA_ID" id="CBA_ID" value="<?php echo KT_escapeAttribute($row_rsLive['CBA_ID']); ?>" size="32" /> </td> </tr> </table></form>