2 Replies - 5788 Views - Last Post: 30 November 2010 - 01:27 PM Rate Topic: -----

#1 LittleZip  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-March 09

Dynamicaly created form creates same name textbox

Posted 26 March 2009 - 09:53 AM

How do I handling multiple text box when a dynamically created Coldfusion form creates multiple text boxes with same names? I have a form that pulls information from two databases based on a users inputted account number. It then populates the form with the information connected with the account number. Each account can have from 1 to about 5 (maybe 6) records. I need to know can the "name" value of the input box be increase by 1 with a loop statement? If so, how? I can't seam to find the Code anywhere or at least point me to the correct source.

Here is the thing the data is not going back into the database that it came from. It will be going into a new database where it will have to create a new entery for each of the rows that show changes in the "DAChange" drop down. I haven't gotten that far, but I am thinking a if statement or to start with each line gets a new record.

I found one javascript code but I have not beable to get it to work. It's like it is missing something.

var name="groupA";
var len=5;
for(var i = 0; i < len; i++)
document.write("<div><input type='text' name='" + name + i + "' /></div>");

<script type="text/javascript" language="javascript">
<!-- Hide from browsers lacking javascript

var tb_group=document.forms["f"].elements["tb"];

// End hiding -->

<form name="f" method="post" action="">
<input type="text" name="tb" value="dog" />
<input type="text" name="tb" value="cat" />
<input type="text" name="tb" value="mouse" />


Thanks for the help

The div tags, fieldset, and legend are for my style sheets

Page one
<cfform action="ss_drop_add_form_part_2_test.cfm" method="post" name="dropadd" id="dropadd">
<h1>Drop/Add Form </h1>
<fieldset class="grouping">
<legend> Student Information</legend>

			  <label for="LastName">Student Email:</label> <input type="Text" name="stdemailid" id="stdemailid" maxlength="9"> @wilsoncc.edu</p>

	  <input type="submit" name="button" id="button" value="Continue to part 2"> 

page2 (ss_drop_add_form_part_2_test.cfm)

<cfquery name="getStdInfo" datasource="wcc_ss">
FROM Course, StudentIndex
WHERE Course.StudentCourseID = StudentIndex.StudentCourseID
AND  StudentID = '#stdemailid#'


<h1>Drop/Add Form </h1>
<fieldset class="grouping">
<legend> Student Information</legend>

<label for="date">Date:</label><input name="date" type="Text" size="9" value="#Dateformat(now(),'mm/dd/yyyy')#">

<label for="StudentID"><br>
  *Student email:</label><input name="StudentID" type="Text" size="9" value="#form.stdemailid#">@wilsoncc.edu

<label for="Curriculum">*Curriculum:</label><input type="Text" name="Curriculum" message="You must enter a Curriculum." required="yes" value="" size="57">

		 <select name="Semester" id="Semester" size="1">
		 <option value="Spring">Spring</option>
		 <option value="Summer">Summer</option>
		 <option value="Fall">Fall</option>

<label>Year</label>  <input type="text" name="Year" value="#Dateformat(now(),'yyyy')#">

<fieldset class="grouping">
<legend>Course Schedule</legend>

<form action="DropAddSubmit" method="post" name="DropAddForm_part2">

<cfoutput query="getStdInfo">
<fieldset class="grouping">
<div>	<p><label>Course:</label><input name="Course" type="text" value="#SectionName#" readonly="true" /></p></div>
 <div>	<p><label>Title:</label><input name="Title" type="text" value="#LongTitle#" readonly="true" /></p><div> 
 <div>	<p><label>Instructor:</label><input name="Instructor" type="text" value="#FacFirstName# #FacLastName#" readonly="true" /></p><div> 
<div>	 <p><label>Credit Hours</label> </p><div> 
<div>	 <p><label>Drop or Add</label>
		 <select name="DAChange" id="DAChange" size="1">
		 <option value="No Change">No Change</option>
		 <option value="Drop">Drop</option>
		 <option value="Add">Add</option>
		 </select></p>  <div> 
  <div>   <p><label>LDA (mm/dd/yyyy):  </label> <input name="LDA1" id="LDA1" size="10" type="text"></p><div> 
<div>	 <p><label>Census Date:</label><input name="CensusDate" type="text" value="#CensusDate#" readonly="true" /></p><div> 
<div>	 <p><label>Reason</label>
	   <select name="Reason1" id="Reason1" required="yes" message="You must enter a Instructor." size="1">
		 <option> </option>
		 <option value="E Employment">E Employment</option>
		 <option value="I Illness (Personal/Family)">I Illness (Personal/Family)</option>
		 <option value="C Child Care Problems">C Child Care Problems</option>
		 <option value="F Financial">F Financial</option>
		 <option value="R Relocation">R Relocation</option>
		 <option value="L Course load too heavy">L Course load too heavy</option>
		 <option value="D Course too difficult">D Course too difficult</option>
		 <option value="X Course not what expected">X Course not what expected</option>
		 <option value="S Transferred to another school">S Transferred to another school</option>
		 <option value="DI Dissatisfied instruction">DI Dissatisfied instruction</option>
		 <option value="DA Disciplinary action">DA Disciplinary action</option>
		 <option value="EA Excessive Absences">EA Excessive Absences</option>
		 <option value="A Administrative Drop">A Administrative Drop</option>
		 <option value="CM Changed mind">CM Changed mind</option>
		 <option value="M Misadvised">M Misadvised</option>
		 <option value="P Personal">P Personal</option>
		 <option value="D Death in t\the Family">D Death in t\the Family</option>
		 <option value="O Other">O Other</option>
		 <option value="U Unknown">U Unknown</option>
		 <option value="DC Deceased">DC Deceased</option>
		 <option value="NP Non-payment">NP Non-payment</option>
		 <option value="G Goal completed">G Goal completed</option>
		 <option value="MD Military Deployment">MD Military Deployment</option>
		 <option value="CP Changed Program">CP Changed Program</option>
		 <option value="NA Never Attended">NA Never Attended</option>
		 <option value="MA Missed Assignments">MA Missed Assignments</option>
		 <option value="SR Student Request">SR Student Request</option>
		 <option value="RE Reinstatement">RE Reinstatement</option>
		 <option value="CI Computer Issues">CI Computer Issues</option>
</fieldset> </cfoutput>
<fieldset class="grouping">
<legend> Additional Information</legend>

<div> <p> Is the student aware of this action?<label>Yes<input name="aware" type="radio" value="yes"></label><label>No<input name="aware" type="radio" value="no"></label></div><p>Comments:
  <textarea name="Comments:" cols="60" rows="5"></textarea>

<fieldset class="grouping">
<legend> Submitters Information</legend>

  <div>  <p>
	 <label for="SubmittedBy">*Submitted By:</label>
	 <input name="SubmittedBy" type="Text" size="57">
   <div> <p>
	 <label for="adjunctemail">*Adjunct Faculty Campus Cruiser e-mail address:</label>
	 <input name="adjunctemail" type="Text" size="57">


Is This A Good Question/Topic? 0
  • +

Replies To: Dynamicaly created form creates same name textbox

#2 Guest_kevhouston*


Re: Dynamicaly created form creates same name textbox

Posted 30 November 2010 - 08:37 AM

<cfloop list = "fieldnamelist" index = "i">
    <input type = "text" Name = "Name#i#">

to display the information you use the evaluate function

<cfloop list = "fieldnamelist" index = "i">
    <input type = "text" Name = "Name#i#">#Evaluate(Name"i")#

This post has been edited by Craig328: 30 November 2010 - 12:59 PM
Reason for edit:: Please to be using the code tags for posting code

Was This Post Helpful? 0

#3 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 2024
  • View blog
  • Posts: 3,609
  • Joined: 13-January 08

Re: Dynamicaly created form creates same name textbox

Posted 30 November 2010 - 01:27 PM

Actually, to take that one better (and because I've always enjoyed no end of aggravation with the evaluate() function), try this: Ditch ColdFusion Evaluate().

Best part of that is: it actually runs quicker (at least it did in the MX7 days when I discovered that link) than Evaluate().

This post has been edited by Craig328: 30 November 2010 - 01:28 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1