Advertisement

08.29.2008 at 06:18AM PDT, ID: 23688738
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

JavaScript Dynamic Forms - auto-incrementing field names and setting maximum entries

Asked by tport_rti in JavaScript, Cold Fusion Markup Language

Tags: ,

I have a dynamic portion of my form that allows people to add additional fields (selecting follow-up and describing the follow-up). The portion of the form looks like this:

<!--- follow-up--->
<tr>
   <td colspan="4">
      <table id="tblFollowup">
      <tr>
                          <td><strong>Followup</strong></td>
                          <td><strong>Description (If other)</strong></td>
      </tr>
                      <tr>
           <td><cfquery name="FollowUp" datasource="#request.DSN#" username="#request.username#" password="#request.password#">
                     select * from tblFollowUp
                                </cfquery>
                                 <cfoutput>
                     <select name="form_idFollowUp[ ]" onKeyDown="typeAhead();">
              <option value="">Please Select</option>
               <cfloop query="FollowUp">
                  <option value="#idFollowUp#" <cfif #getrecord.idfollowup# eq "#idFollowUp#">selected</cfif>>#FollowUp#</option>
               </cfloop>
                     </select>
                           </cfoutput>
                          </td>
                     <td><input name="OtherFollowUp[ ]" type="text" size="30" maxlength="255"></td>
           <td><!---<input type="button" value="Remove" onclick="removeRow(this.parentNode.parentNode)"/>---></td>
              </tr>
              </table>
<a HREF="javascript:void(0)" name="contact" onClick="addRowToTable2();">[Add Another Follow Up]</a>
      </td>
 </tr>
 <!--- end follow-up--->


The problem is, when I submit the form I need the field names to increase (example: form_idFollowup[1], form_idFollowup[2]) instead of submitting in a comma delimited list as one field name. In addition to that, I'm trying to limit the amount of additional entries (max 5).

I would love to know how to pre-populate these for editing (so when they save the page and return the fields are auto-shown and populated) but that might be a different post...

Here's the JavaScript I have thus far...

Thank you in advance for reading this and any assistance you might provide.
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
function addRowToTable2()
                              {
                                var tbl = document.getElementById('tblFollowup');
                                var lastRow = tbl.rows.length;
                                // if there's no header row in the table, then iteration = lastRow + 1
                                //var iteration = lastRow;
                              	var iteration = lastRow + 1;
                                var row = tbl.insertRow(lastRow);
                                
                                //  cell 0
                                var cell0 = row.insertCell(0);
                                var el =  document.createElement("select");
								el.name = 'idFollowUp[]';
								el.options[0] = new Option('Please Select', '0');
								el.options[1] = new Option('Call', '1');
								el.options[2] = new Option('Send Email', '2');
								el.options[3] = new Option('Send Thank You Note', '3');
								el.options[4] = new Option('Send Marketing Material', '4');
								el.options[5] = new Option('Send Proposal', '5');
								el.options[6] = new Option('Introduce to Relevant RTI Staff', '6');
								el.options[7] = new Option('Re-engage in 6-12 months', '7');
								el.options[8] = new Option('Other', '8');
								cell0.appendChild(el);
                                
								 //  cell 1
                                var cell1 = row.insertCell(1);
                                var el = document.createElement('input');
                                el.type = 'text';
                                el.name = 'OtherFollowUp[]';
                                el.size = 30;
                                cell1.appendChild(el);
								
                                var cell2 = row.insertCell(2);
                                var el = document.createElement('input');
                                el.type = 'button';
                                el.value = 'Remove';
                                el.onclick=function(){removeRow(row)};
                                cell2.appendChild(el);
                              } 
function removeRow(o){
return o.parentNode.removeChild(o);
}
[+][-]08.29.2008 at 06:25AM PDT, ID: 22345098

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.29.2008 at 06:48AM PDT, ID: 22345317

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: JavaScript, Cold Fusion Markup Language
Tags: JavaScript, ColdFusion, IE6 IE7
Sign Up Now!
Solution Provided By: hielo
Participating Experts: 1
Solution Grade: A
 
 
[+][-]08.29.2008 at 10:41AM PDT, ID: 22347603

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628