close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Update Record Behaviour has me baffled!

Thread began 9/26/2011 9:14 am by acaciasd344844 | Last modified 9/26/2011 2:38 pm by acaciasd344844 | 562 views | 2 replies |

acaciasd344844

Update Record Behaviour has me baffled!

Hi,

I will try and explain this as best and clearly as I can. I have a form that has to perform an insert and an update at the same time. And so far the page is performing that function.

However, the problem is that the Update Record Server Behavior is not selecting the correct record when the relevant submit button is selected.

I have a dataassist repeat region containing a list of serial numbers relating to a dataset. Inside this region I also have a button. So for each serial number there is a submit button next to it. Its for ease of selection for the end user.

From what I can gather and after playing around for hours with the database, is that the server behavior is selecting the last row in the list even though I selected the first row. Its as though the Server Behavior is ignoring the Key Column and Value that I have given it. I have displayed the key column on the page and can see the values in question. But I cant for the life of me figure out what I'm doing wrong. As I said it is updating the database tables. The Insert works correctly for one table and then the Update populates the table. But its always the last item in the list.

Should I try making the update behavior run first and then add the insert behavior? I wouldn't have thought that should have made such a difference!

I will add a zip file for your attention

Hope you can help


cheers


john

Attached Files
m_jobdetails_addbox.zip
Sign in to reply to this post

Jason ByrnesWebAssist

the problem is that the form tags are outside of the repeate region. this men that the page is being create with one form on it, and inside that one form the form elements are being repeated.


change the code at lines 591 - 632:

php:
<td colspan="3"><form id="form1" name="form1" method="POST">

        <?php
    
// RepeatSelectionCounter_1 Begin Loop
    
$RepeatSelectionCounter_1_IterationsRemaining $RepeatSelectionCounter_1_Iterations;
    while(
$RepeatSelectionCounter_1_IterationsRemaining--){
        if(
$RepeatSelectionCounterBasedLooping_1 || $row_Recordsetsearchallocatedstock){
?>
<table width="100%" border="0">
          <tr>
            <td><a href="m_jobdetails_addbox.php?stockname=<?php echo $row_Recordsetshowallproducts['subproducttypesid']; ?>&productgrp=<?php echo $row_Recordsetshowallproducts['groupid']; ?>&customerid=<?php echo $row_showcustomerdetails['customerid']; ?>&workorderid=<?php echo $row_showcustomerdetails['workorderid']; ?>"><?php echo $row_Recordsetsearchallocatedstock['serialnumber']; ?></a><span class="style26"><strong><strong><?php echo $row_Recordsetsearchallocatedstock['stockid']; ?></strong></strong></span>
                  <label>
                  <input name="stockyid" type="text" id="stockyid" value="<?php echo $row_Recordsetsearchallocatedstock['stockid']; ?>" />
                  </label>
                  <input name="hf_subprodid" type="hidden" id="hf_subprodid" value="<?php echo $row_Recordsetsearchallocatedstock['stockname']; ?>" />
                  <input name="hf_workorderid" type="hidden" id="hf_workorderid" value="<?php echo $row_showcustomerdetails['workorderid']; ?>" />
                  <input name="hf_customerid" type="hidden" id="hf_customerid" value="<?php echo $row_showcustomerdetails['customerid']; ?>" />
                  <input name="hf_productgrp" type="hidden" id="hf_productgrp" value="<?php echo $row_Recordsetsearchallocatedstock['groupid']; ?>" />
                  <input name="hf_price" type="hidden" id="hf_price" value="<?php echo $row_Recordsetsearchallocatedstock['price']; ?>" />
                  <input name="hf_stockid" type="hidden" id="hf_stockid" value="<?php echo $row_Recordsetsearchallocatedstock['stockid']; ?>" />
                  <input name="allocatedto" type="hidden" id="allocatedto" value="Customer" />
                  <input name="hf_installeddate" type="hidden" id="hf_installeddate" value="<?php echo date ('Y-m-d H:i:s'); ?>" />
                  <input name="hf_installedby" type="hidden" id="hf_installedby" value="<?php echo $_SESSION['MM_Username']; ?>" />
                  <label>
                  <input type="submit" name="button" id="button" value="Submit" />
                    MUST NOT SHOW ALLOCATED BOXES</label></td>
          </tr>
        </table>
<?php
    
// RepeatSelectionCounter_1 Begin Alternate Content
    
else{
?>
<?php 
// RepeatSelectionCounter_1 End Alternate Content
        
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
            if(!
$row_Recordsetsearchallocatedstock && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining 0;}
            
$row_Recordsetsearchallocatedstock mysql_fetch_assoc($Recordsetsearchallocatedstock);
        }
        
$RepeatSelectionCounter_1++;
    } 
// RepeatSelectionCounter_1 End Loop
?>
            
            
      </form>      </td>




to:

php:
<td colspan="3">

        <?php
    
// RepeatSelectionCounter_1 Begin Loop
    
$RepeatSelectionCounter_1_IterationsRemaining $RepeatSelectionCounter_1_Iterations;
    while(
$RepeatSelectionCounter_1_IterationsRemaining--){
        if(
$RepeatSelectionCounterBasedLooping_1 || $row_Recordsetsearchallocatedstock){
?>
<form id="form1_<?php echo $row_Recordsetsearchallocatedstock['stockid']; ?>" name="form1_<?php echo $row_Recordsetsearchallocatedstock['stockid']; ?>" method="POST"><table width="100%" border="0">
          <tr>
            <td><a href="m_jobdetails_addbox.php?stockname=<?php echo $row_Recordsetshowallproducts['subproducttypesid']; ?>&productgrp=<?php echo $row_Recordsetshowallproducts['groupid']; ?>&customerid=<?php echo $row_showcustomerdetails['customerid']; ?>&workorderid=<?php echo $row_showcustomerdetails['workorderid']; ?>"><?php echo $row_Recordsetsearchallocatedstock['serialnumber']; ?></a><span class="style26"><strong><strong><?php echo $row_Recordsetsearchallocatedstock['stockid']; ?></strong></strong></span>
                  <label>
                  <input name="stockyid" type="text" id="stockyid" value="<?php echo $row_Recordsetsearchallocatedstock['stockid']; ?>" />
                  </label>
                  <input name="hf_subprodid" type="hidden" id="hf_subprodid" value="<?php echo $row_Recordsetsearchallocatedstock['stockname']; ?>" />
                  <input name="hf_workorderid" type="hidden" id="hf_workorderid" value="<?php echo $row_showcustomerdetails['workorderid']; ?>" />
                  <input name="hf_customerid" type="hidden" id="hf_customerid" value="<?php echo $row_showcustomerdetails['customerid']; ?>" />
                  <input name="hf_productgrp" type="hidden" id="hf_productgrp" value="<?php echo $row_Recordsetsearchallocatedstock['groupid']; ?>" />
                  <input name="hf_price" type="hidden" id="hf_price" value="<?php echo $row_Recordsetsearchallocatedstock['price']; ?>" />
                  <input name="hf_stockid" type="hidden" id="hf_stockid" value="<?php echo $row_Recordsetsearchallocatedstock['stockid']; ?>" />
                  <input name="allocatedto" type="hidden" id="allocatedto" value="Customer" />
                  <input name="hf_installeddate" type="hidden" id="hf_installeddate" value="<?php echo date ('Y-m-d H:i:s'); ?>" />
                  <input name="hf_installedby" type="hidden" id="hf_installedby" value="<?php echo $_SESSION['MM_Username']; ?>" />
                  <label>
                  <input type="submit" name="button" id="button" value="Submit" />
                    MUST NOT SHOW ALLOCATED BOXES</label></td>
          </tr>
        </table></form>
<?php
    
// RepeatSelectionCounter_1 Begin Alternate Content
    
else{
?>
<?php 
// RepeatSelectionCounter_1 End Alternate Content
        
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
            if(!
$row_Recordsetsearchallocatedstock && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining 0;}
            
$row_Recordsetsearchallocatedstock mysql_fetch_assoc($Recordsetsearchallocatedstock);
        }
        
$RepeatSelectionCounter_1++;
    } 
// RepeatSelectionCounter_1 End Loop
?>
            
            
            </td>




this way each repeated row will be a unique form.

Sign in to reply to this post

acaciasd344844

Thanks Jason,

As soon as I read what you had written above it made complete sense. I couldn't see the wood for the trees. I have done it so many times, but just couldn't figure it out.

Thanks Again

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...