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

Web development tutorial

Multiple Updatable Textfields - Results Page

Tutorial created by FrankJay, Famous Idea Trading 8cc

Categories: Data Bridge

rating

Using WebAssist DataBridge to generate the back-end pages works really great and is a massive timesaver in the development process. Now imagine if your client has a database of a few hundred products and wants to update the price of a few records. Normally they would need to drill down to the required product, either by search or by scrolling down the page, and then selecting the update button to view the details. They then need to adjust the price field and update the record. Ending up back at the details page or the results page. And then starting the process all over again.

Pretty time-consuming!

A solution is to offer updatable input textfields on your results page with an updatable button that when pressed, will update all the price fields that have been changed for this page.

A massive time-saving to your client.

This tutorial will take you through the steps necessary to be able to accomplish this functionality.

arrow downWhat you need to start

Dreamweaver CS3 or later
Data Bridge extension
A Results Page

arrow downBrief Overview of the Steps Required

1. To manually adjust the regular text to become form element input textfields.
2. To remove the default Dreamweaver Repeat Region
3. Replace with DataAssist Repeat Selection server behavior
4. Insert a button within the form element on the page
5. Apply the DataAssist Multiple Records Update server behavior
6. Test the functionality and tweak

arrow downLet’s begin!

A side by side screenshot of the standard and adjusted results page. For the purposes of this tutorial, I'm going to select three columns to become input textfields, namely: Price, Promo And Status. Take note that this tutorial is not based on updating one row at a time, but instead, updating all the rows on the one page, and the page hereafter, and so on.

Step 1: Adjust Your Dynamic Text to Input Text Fields

Step back for a moment to before you use the DataAssist Pages to create your pages. Make sure that on the results page you include the fields that you would like to become updatable text input fields.

In Dreamweaver, 0pen your DataBridge generated results page that you want to adjust.

In code view, scroll down the page to this div:

<div class="WADAResultsTableWrapper">, or

In design view, select the column’s dynamic text and then switch over to code view.


Your dynamic text will be highlighted and displayed in code view as seen in the screenshot below.


We now need to manually hand code this dynamic text to become updatable input text fields as in the screenshot below. We are going to give this input text field a name so that it can be identified and used later in the tutorial.


Here is a cleaner look of the first line of code above:

<td class="WADAResultsTableCell"><input name="multi_price" type="text" value="<?php echo($row_WADAwa_products_tutorial['wa_ProductPrice']); ?>" ></td>

I have included some in-line styling in the form of size as shown in the screenshot below:


Save your page.

Step 2: Remove the Dreamweaver Repeat Region

By default, the Dreamweaver repeat region is used to repeat the number of rows that has been set to display your records on your results page.

When substituting and using the WebAssist Repeat Selection server behavior, some magic will happen and explained further along in this tutorial.

You need to remove the default Dreamweaver repeat region. The repeat region would start with the code below:

<?php do { ?>

And end with:

<?php } while ($row_WADAwa_products_tutorial = mysql_fetch_assoc($WADAwa_products_tutorial)); ?>

This repeat region block of code will be wrapped around the table row containing all the table data columns that will be displayed on the results page.

To locate this block of code, switch to design view, and select the repeat tab, then switch back to code view where you will see the block of code selected is highlighted.

Make sure that you do not delete the whole block of code, but only the beginning and ending PHP code of the repeat region as indicated above.

Once done, save your page.

Step 3: Apply the WebAssist Repeat Selection

Before we move on, you need to find out how many rows were set, in the DataAssist Pages wizard, to display on the results page. By default this is set to 10 records.

Next we need to select the block of code for the row that was previously used to apply the Dreamweaver repeat region.

Go to your status bar and using the tag selector, you can select this block of code simply by clicking on the <tr> tag. Hover your mouse over the selected <tr> tag and it will display some class information that matches the code below to confirm that you have the right <tr> selected.

<tr class="<?php echo($WARRT_AltClass1->getClass(true)); ?>">

A screenshot of the tag selector:


Alternatively, you can also select this row from the server behavior panel. You are looking for a dynamic attribute for the table row class to match the one mentioned above.

In the server behavior panel, just select this dynamic attribute and move over to code view where you will see that this code block for the row has been selected.


Now that you have this code block selected and you know the number of times it needs to be repeated, you can now apply the WebAssist Repeat Selection server behavior.

Go to the server behavior panel and click the plus icon, then choose:

WebAssist >> DataAssist >> Repeat Selection


This will open the DataAssist Repeat Selection popup window. It has three options that need to be completed, namely:


Recordset: WADAwa_products_tutorial (only one recordset is available from this drop-down list)
Repetitions: 15 (the number of times you want the road to be repeated)
Alternative content: <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>

This alternative content is another column that is added by default. It will allow you to place additional content into this additional column. In our case, we do not need this. Go ahead and select then delete, leaving the alternative content block empty.

When this server behavior is applied, the Repeat Selection code is now placed in a position that will include the table headers for each row.


The Repeat Selection code that has been added to the page, has not been placed where the original Dreamweaver repeat region 'do' code appeared. You will need to locate the Repeat Selection begin loop code:

<?php
// RepeatSelectionCounter_1 Begin Loop
$RepeatSelectionCounter_1_IterationsRemaining = $RepeatSelectionCounter_1_Iterations;
while($RepeatSelectionCounter_1_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_1 || $row_WADAwa_products_tutorial){
?>


You should cut the code block above and paste it above the opening table row tag that will display all your dynamic content.

Likewise, the php code block for the Begin Alternative Content, to the End Loop closing php tag was all placed outside of the end table tag.

<?php
} // RepeatSelectionCounter_1 Begin Alternate Content
.
.
.
} // RepeatSelectionCounter_1 End Loop
?>


You should also cut the code above and paste it just inside the closing table tag that is found just above the container for your recordset navigation.


Once all of the Repeat Selection code has been placed into the correct position, the table row headers would not be repeated for every row:

Step 4: Insert an "Update All" Button

The placement of the button code must be after the end table tag </table> and before the beginning of the div container for the results navigation:

<div class="WADAResultsNavigation">



You can proceed and delete the name "Records" that is highlighted in the screenshot above, and then in its place, insert your button code shown here below:

<div class="update-right"><input type="submit" name="update_all" value="Update"></div>

I have just added a class and placed the button code inside a div tag that will float the update button to the right-hand side of the page. It is vital that this inserted update button is still within the form element of the page.



This button will be used as a trigger to apply the WebAssist Multiple Records Update server behavior.

After completion of this tutorial you can apply custom styling to this button to match the look and feel of your page.

Save your page.

Step 5: Apply WebAssist Multiple Records Update

Go to the server behavior panel, click on the plus icon, and then click:

WebAssist >> DataAssist >> Update >> Multiple Record Updates.



It is key that you apply the WebAssist Repeat Selection server behavior. You need a Repeat Selection for the Multiple Record Updates server behavior to work.



Under the General tab of the Update Multiple Records user interface, there are seven options that need to be completed. In this case, we are only going to require five of these options, namely:

Trigger: Button: update_all pressed - this is the button that we inserted earlier in the tutorial.
Repeated form: Repeat Selection (WADAwa_products_tutorial, 15) – 15 signifies the rows to be repeated.
Connection: connWAproduct - your connection would be different to this tutorial.
Table: wa_products_tutorial - your table would also be different to this tutorial.
Key column: wa_ProductID

Go To (optional): Will be left blank. After the update has occurred, we will remain on the same page.
Pass original querystring: is not necessary for this tutorial to be enabled.

Click on the Bindings tab to proceed to the next step. In the Bindings panel we are going to select the columns for the required updatable fields and bind their values from the value drop-down menu options that are listed. These listed options, from the named input updatable text fields, were created in step one of this tutorial.


The value drop down menu lists the fields from the Repeat Selections server behavior.

If you did not select the values from the drop-down list, they would be merely static values.

We need to get the repeated field values and must therefore select these values from the drop-down list.

Your final selection of the values for your selected columns should match the screenshot below:


Click finish and that should do it.

The WebAssist Repeat Selection server behavior has automatically done the following:

It has put in a hidden form element to keep track of the ID,

It has renamed all your form elements with a counter - so it can keep track of which form element goes with which ID


Without the above, the Multiple Records Update server behavior, would not be able to to be applied.

Save your page.

Step 6: Testing The Functionality, Making Changes

Before testing, just ensure that you have a backup of your database should something go wrong.

During testing, it seemed as if the Multiple Update Records did not work. It seems so at first glance but when retesting it does actually show when you refresh the page.

When you applied the Update Multiple Records server behavior, the code block is inserted below that of the recordset. So the update is being applied after the recordset code, which is still displaying the old results. Refresh your page to display the updated information.

An easy solution to correct this is to change the sequence of the code on the page.


The screenshot above clearly indicates the sequence of the code on the page.

Select the Update Multiple Records server behavior under the server behaviors panel and switch over to code view. You will see that the code block has been selected. Below is a sample of the opening and closing lines of code for the Update Multiple Records server behavior.

<?php
// WA DataAssist Multiple Updates
if (isset($_POST["update_all"]) || isset($_POST["update_all_x"])) // Trigger
...
header("Location: ".$WA_redirectURL);
}
}
?>


Go ahead and cut this code block, making sure to delete the blank line that was left behind after cutting the code.

Next, select the recordset listed in the server behaviors panel. Switch over to the code view. A sample of the opening and closing lines of code for the recordset:

<?php
$maxRows_WADAwa_products_tutorial = 15;
$pageNum_WADAwa_products_tutorial = 0;
...
$totalPages_WADAwa_products_tutorial = ceil($totalRows_WADAwa_products_tutorial/$maxRows_WADAwa_products_tutorial)-1;
?>


Insert a blank line above the recordset code block and paste here the Update Multiple Records server behavior code block.

A screenshot showing the correct sequence of the server behaviors on the page:


Save your page and test.

arrow downTutorial in PDF Version

To follow along with a hard copy of this tutorial, click on the download link below.

01-Multiply-Update-Text-Fields-Tutorial.pdf

arrow downReviews and comments

Comments will be sent to the author of this tutorial and may not be answered immediately. For general help from WebAssist, please visit technical support.

Sign in to add comments
rating

Justin Hood: 4 Years, 1 Month, 1 Week, 1 Day, 9 Hours, 40 Minutes ago

Great tutorial, Frank. I would make note that your pages were based on the 'Product Administration' Application Type preset in the DataAssist Create Pages Wizard. While your steps will work (with some modifications) for any DataAssist results page, the steps would be considerably different for say - Product Catalog. Again, great tutorial!

rating

this_is_me: 3 Years, 9 Months, 1 Week, 1 Day, 13 Hours, 21 Minutes ago

Thanks a lot, Frank!
I had pulled my hair because after submitting the changes they did not show up in the refreshed form, although the changes were written correctly into the database. Changing the sequence of the code as you described at the end of the tutorial did the trick!
5 stars for your comprehensive explanations!

FrankJay: 3 Years, 9 Months, 1 Week, 1 Day, 43 Minutes ago

Thank you for your comments. I'm truly thrilled that the tutorial has helped you. Regards Frank.

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.