School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,481 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,776 people online right now. Registration is fast and FREE... Join Now!




Dynamicaly created form creates same name textbox

 

Dynamicaly created form creates same name textbox

LittleZip

26 Mar, 2009 - 08:53 AM
Post #1

New D.I.C Head
*

Joined: 26 Mar, 2009
Posts: 2

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




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

window.onload=function()
{
var tb_group=document.forms["f"].elements["tb"];
alert(tb_group[1].value);
};

// End hiding -->
</script>
</head>
<body>

<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" />
</form>

</body>
</html>



Thanks for the help
LittleZip

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

Page one
CODE


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

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

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



page2 (ss_drop_add_form_part_2_test.cfm)

CODE

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

</cfquery>




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

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

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

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

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

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


<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>
         </select></p><div>
</fieldset> </cfoutput>
</form>
</fieldset>
<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:
  </label>
  <textarea name="Comments:" cols="60" rows="5"></textarea>
  </p><div>
    
</fieldset>

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

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






</fieldset>
    




User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 03:57AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month