close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Ajax with Repeat Selection

Thread began 9/19/2009 11:43 am by Bknvc1111729 | Last modified 9/27/2009 8:30 pm by Bknvc1111729 | 1521 views | 2 replies |

Bknvc1111729

Ajax with Repeat Selection

Ok, I have several issues with this problem so I am breaking it down piece by piece. Maybe one will resolve the rest. I will attach the files to this post.

A quick description of what I am doing. There are three dropdown lists that hold values to be converted from metric to standard measurments. There are three textfields that hold the results of the calculations that the ajax code performs before displaying the reults. Each dropdown corresponds to a specific textfield.

First I built the basic page with just the necessay coding to make sure the ajax was working (Start.php). Using the DataAssist Insert Single Record I could get everything to work and upload perfectly.

The first problem I have which is what I am addressing now is that when I applied the DataAssist Repeat Selection to the page the first row works like it is suppose to, but the other rows will not. Second if you try to make a selection from one of the drop downs in say row 2-15 then it returns the data to the textfield in row one and not the row that was used. You can see the code with the attachment Step1.php.

I have also attached what I thought th final code should have been (Finished.php). This might help somehow.

Attached Files
Finished.zip
Start.zip
Step1.zip
cheaprims.zip
Sign in to reply to this post

Jason ByrnesWebAssist

The problem is all of the form elements have the same name.

You need to use the increment counter to give each on a unique name and pass the incrrement counter in your ajax function call:

php:
<?php

      
// RepeatSelectionCounter_1 Begin Loop
      
$RepeatSelectionCounter_1_IterationsRemaining $RepeatSelectionCounter_1_Iterations;
      while(
$RepeatSelectionCounter_1_IterationsRemaining--){
          if(
$RepeatSelectionCounterBasedLooping_1 || $row_None){
    
?>
    
      <tr>
        <td><select name="Width_<?php echo $RepeatSelectionCounter_1?>" id="Width_<?php echo $RepeatSelectionCounter_1?>" onChange="updateDiameter(<?php echo $RepeatSelectionCounter_1?>);">
            <option value="" selected="selected"></option>
            <option value="235">235</option>
          </select>
        </td>
        <td><select name="AspectRatio_<?php echo $RepeatSelectionCounter_1?>" id="AspectRatio_<?php echo $RepeatSelectionCounter_1?>" onChange="updateDiameter(<?php echo $RepeatSelectionCounter_1?>);">
            <option value="" selected="selected"></option>
            <option value="35">35</option>
          </select>
        </td>
        <td><select name="Diameter_<?php echo $RepeatSelectionCounter_1?>" id="Diameter_<?php echo $RepeatSelectionCounter_1?>" onChange="updateDiameter(<?php echo $RepeatSelectionCounter_1?>);">
            <option value="" selected="selected"></option>
            <option value="19">19</option>
          </select>
        </td>
        <td><input name="SectionWidth_<?php echo $RepeatSelectionCounter_1?>" type="text" id="SectionWidth_<?php echo $RepeatSelectionCounter_1?>" value="" size="3" /></td>
        <td><input name="SectionHeight_<?php echo $RepeatSelectionCounter_1?>" type="text" id="SectionHeight_<?php echo $RepeatSelectionCounter_1?>" value="" size="3" /></td>
        <td><input name="OverallHeight_<?php echo $RepeatSelectionCounter_1?>" type="text" id="OverallHeight_<?php echo $RepeatSelectionCounter_1?>" value="" size="3" /></td>
      </tr>
      
    <?php
      
// RepeatSelectionCounter_1 Begin Alternate Content
      
else{
    
?>
    <?php // RepeatSelectionCounter_1 End Alternate Content
        
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
            if(!
$row_None && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining 0;}
            
$row_None mysql_fetch_assoc($None);
        }
        
$RepeatSelectionCounter_1++;
    } 
// RepeatSelectionCounter_1 End Loop
    
?>






then to use the increment in the funct5ion call, change the script to:

function updateDiameter(i)
{
var section = parseFloat(document.getElementById('Width_'+i).value * 1);
var aspect = parseFloat(document.getElementById('AspectRatio_'+i).value * 1);
var diameter = parseFloat(document.getElementById('Diameter_'+i).value * 1);

section_width = (section / 25.4);
document.getElementById('SectionWidth_'+i).value = section_width.toFixed(2);

section_height = (section_width * aspect / 100);
document.getElementById('SectionHeight_'+i).value = section_height.toFixed(2);

overall = ((section_height * 2) + diameter);
document.getElementById('OverallHeight_'+i).value = overall.toFixed(1);

}
Sign in to reply to this post

Bknvc1111729

Jason Byrnes,

I know I am late at getting back to you with my thanks for your help. It works great.


Bknvc1

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...