Link to home
Start Free TrialLog in
Avatar of kevp75
kevp75Flag for United States of America

asked on

How to get part of a form values to stay...

I have a job application form built.  Part of it, allows you to click a link to display more sections for 'Previous Employment'.

My issue is, because the javascript that controls that link (section) clones the entire section I am finding that I cannot simply put value="<%=theField%>" as there may be more than one section.

What can I do?  I need to keep the functionality as it is...  (here's a link... http://www.lightbridgehospice.org/Careers/App.asp  if you click the 'Add Another Employer' you will see what I mean by clone...)
Avatar of nee_nov
nee_nov

hi,

Can you tell where and why you need to assign the value  -- (Value="<%=theField%>" ) ? And where do these value come from?
@kevp75

Can you bit more clear as to what you are looking for....


If you are looking for cloning the element values as per the last textbox....? then get the value of the Textbox(arrayIndex) for the last textbox and then replicate its value further.

Hope this is what you are looking at....i would be able to look into the problem in more descriptive manner when you have the issue put forth

Avatar of kevp75

ASKER

i have mini-me today, I will post code later on
hahahah sure....

CHEERS...
Avatar of kevp75

ASKER

sorry for the wait folks....here's my code:

function delRow(oThis)
{
      var index = oThis.parentNode.parentNode.rowIndex;
      var table = document.getElementById('empTbl');
      var tr;
      var i;
      for (i = 0 ; i < 7 ; i++)
      {
            table.deleteRow(index - i);
      }
}
function addRow()
{
      var table = document.getElementById('empTbl');
      var tbody = table.getElementsByTagName('tbody')[0];
      var tr;
      var i;
      for (i = 0 ; i < 7 ; i++)
      {
            tr = table.insertRow(table.rows.length);
            cloneCells(table.rows[i], tr);
      }
}
function cloneCells(oSourceTR, oDestinaionTR)
{
      var oDestinaionCell;
      var inputs;
      var i;
      var j;
      for (i = 0 ; i < oSourceTR.cells.length ; i++)
      {
            oDestinaionCell = oDestinaionTR.insertCell(oDestinaionTR.cells.length);
            oDestinaionCell.innerHTML = oSourceTR.cells[i].innerHTML;
            inputs = oDestinaionCell.getElementsByTagName("input");
            for (j = 0 ; j < inputs.length ; j++)
            {
                  inputs[j].value = "";
            }
      }
}


<!--Rest of page and form-->
            <tr>
                  <td><div align="right"><a href='#' onclick="addRow();return false;">Add Another Employer</a></div>
            <table width="100%" border="0" cellspacing="0" cellpadding="2" id="empTbl" style="border:1px solid #000;">
            <tbody>
                              <tr>
                                    <td>Company Name: <input name="appEmpC" type="text" class="textbox" id="appEmpC" value="" size="77" />
                                    Telephone: <input name="appEmpPhone" type="text" class="textbox" id="appEmpPhone" value="" size="23" /></td>
                              </tr>
                              <tr>
                                    <td>Address: <input name="appEmpAdd" type="text" class="textbox" id="appEmpAdd" value="" size="75" />
                                    Dates Of Employment: <input name="appEmpDF" type="text" class="textbox" id="appEmpDF" value="" size="7" /> to <input name="appEmpDT" type="text" class="textbox" id="appEmpDT" value="" size="7" /></td>
                              </tr>
                              <tr>
                                    <td>Supervisor's Name:
                                          <input name="appEmpSup" type="text" class="textbox" id="appEmpSup" value="" size="80" />
                                          Pay $
                                          <input name="appEmpPay" type="text" class="textbox" id="appEmpPay" value="" size="7" />
                                          per
                                          <input name="appEmpRate" type="text" class="textbox" id="appEmpRate" value="" size="7" /></td>
                              </tr>
                              <tr>
                                    <td>Job Title/Duties: <input name="appEmpDuties" type="text" class="textbox" id="appEmpDuties" value="" size="117" /></td>
                              </tr>
                              <tr>
                                    <td>Reason For Leaving
                                          <input name="appEmpLeft" type="text" class="textbox" id="appEmpLeft" value="" size="113" /></td>
                              </tr>
                              <tr style="display:none">
                                  <td><a style="padding:5px 0 5px 715px;" href='#' onclick="delRow(this);return false;">Remove Employer</a></td>
                            </tr>
                              <tr>
                                  <td><hr /></td>
                            </tr>
            </tbody>
            </table>                  </td>
            </tr>
Avatar of kevp75

ASKER

when I request the field values the come through as a comma-dlimited list, so I split on that, do an if isarray check (if valid, then display in the email that gets sent), but what I have is validation checks on certain fields above this area, and if one fails, I need to be able to keep the values the user typed in, into the fields.  However when a potential applicant hits submit, and a validation fails, this section goes back to being only one section (meaning if they had 'Added' another prev. employer....the one they added disappears)

I know I need to put in value="<%=request.form("appEmpXXXX")%>, however it is pointless, since:

A)  It's a comma-delimited list
b)  The extra section(s) disappear anyways...
SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kevp75

ASKER

hey amit!

tried what you suggested...and, well, it semi-worked.

The values get populated, however what is being displayed is the comma-delimited list.

here's what I have now for this section:
                  <%
                  If (request.form("appEmpC") <> "") then
                        arrEmpC = Split(request.form("appEmpC"), ",")
                        EmployerCount = UBound(arrEmpC) - LBound(arrEmpC) + 1
                  else
                        EmployerCount = 1
                  end if
                  %>
            <tbody>
                  <%
                        FOR IC = 1 to EmployerCount
                  %>

                              <tr>
                                    <td>Company Name: <input name="appEmpC" type="text" class="textbox" id="appEmpC" value="<%=appEmpC&IC%>" size="77" />
                                    Telephone: <input name="appEmpPhone" type="text" class="textbox" id="appEmpPhone" value="<%=appEmpPhone&IC%>" size="23" /></td>
                              </tr>
                              <tr>
                                    <td>Address: <input name="appEmpAdd" type="text" class="textbox" id="appEmpAdd" value="<%=appEmpAdd&IC%>" size="75" />
                                    Dates Of Employment: <input name="appEmpDF" type="text" class="textbox" id="appEmpDF" value="<%=appEmpDF&IC%>" size="7" /> to <input name="appEmpDT" type="text" class="textbox" id="appEmpDT" value="<%=appEmpDT&IC%>" size="7" /></td>
                              </tr>
                              <tr>
                                    <td>Supervisor's Name:
                                          <input name="appEmpSup" type="text" class="textbox" id="appEmpSup" value="<%=appEmpSup&IC%>" size="80" />
                                          Pay $
                                          <input name="appEmpPay" type="text" class="textbox" id="appEmpPay" value="<%=appEmpPay&IC%>" size="7" />
                                          per
                                          <input name="appEmpRate" type="text" class="textbox" id="appEmpRate" value="<%=appEmpRate&IC%>" size="7" /></td>
                              </tr>
                              <tr>
                                    <td>Job Title/Duties: <input name="appEmpDuties" type="text" class="textbox" id="appEmpDuties" value="<%=appEmpDuties&IC%>" size="117" /></td>
                              </tr>
                              <tr>
                                    <td>Reason For Leaving
                                          <input name="appEmpLeft" type="text" class="textbox" id="appEmpLeft" value="<%=appEmpLeft&IC%>" size="113" /></td>
                              </tr>
                              <tr style="display:none">
                                  <td><a style="padding:5px 0 5px 715px;" href='#' onclick="delRow(this);return false;">Remove Employer</a></td>
                            </tr>
                              <tr>
                                  <td><hr /></td>
                            </tr>
                              <%next%>
            </tbody>
Avatar of kevp75

ASKER

and..one thing I noticed...when you first load the page, there are 1's in every field in this section
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kevp75

ASKER

ok...using:
                  <%
                        FOR IC = LBound(arrEmpC) to UBound(arrEmpC)
                  %>

on initial page load throughs out the error on lbound, and I only get a Type mismatch: 'appEmpC'
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kevp75

ASKER

doh..missed the initial
arrEmpC = Split(" ", ","), put that in, and it fixed the lbound

but the type mismatch error on 'appEmpC' still shows
Avatar of kevp75

ASKER

here's my full code now:
            <table width="100%" border="0" cellspacing="0" cellpadding="2" id="empTbl" style="border:1px solid #000;">
                  <%
                  If (request.form("appEmpC") <> "") then
                        arrEmpC = Split(request.form("appEmpC"), ",")
                  else
                        arrEmpC = Split(" ", ",")
                  end if
                  If (request.form("appEmpPhone") <> "") then
                        arrEmpPhone = Split(request.form("appEmpPhone"), ",")
                  else
                        arrEmpPhone = Split(" ", ",")
                  end if
                  If (request.form("appEmpAdd") <> "") then
                        arrEmpAdd = Split(request.form("appEmpAdd"), ",")
                  else
                        arrEmpAdd = Split(" ", ",")
                  end if
                  If (request.form("appEmpDF") <> "") then
                        arrEmpDF = Split(request.form("appEmpDF"), ",")
                  else
                        arrEmpDF = Split(" ", ",")
                  end if
                  If (request.form("appEmpDT") <> "") then
                        arrEmpDT = Split(request.form("appEmpDT"), ",")
                  else
                        arrEmpDT = Split(" ", ",")
                  end if
                  If (request.form("appEmpSup") <> "") then
                        arrEmpSup = Split(request.form("appEmpSup"), ",")
                  else
                        arrEmpSup = Split(" ", ",")
                  end if
                  If (request.form("appEmpPay") <> "") then
                        arrEmpPay = Split(request.form("appEmpPay"), ",")
                  else
                        arrEmpPay = Split(" ", ",")
                  end if
                  If (request.form("appEmpRate") <> "") then
                        arrEmpRate = Split(request.form("appEmpRate"), ",")
                  else
                        arrEmpRate = Split(" ", ",")
                  end if
                  If (request.form("appEmpDuties") <> "") then
                        arrEmpDuties = Split(request.form("appEmpDuties"), ",")
                  else
                        arrEmpDuties = Split(" ", ",")
                  end if
                  If (request.form("appEmpLeft") <> "") then
                        arrEmpLeft = Split(request.form("appEmpLeft"), ",")
                  else
                        arrEmpLeft = Split(" ", ",")
                  end if

                  %>
            <tbody>
                  <%
                        FOR IC = LBound(arrEmpC) to UBound(arrEmpC)

                  %>

                              <tr>
                                    <td>Company Name: <input name="appEmpC" type="text" class="textbox" id="appEmpC" value="<%=appEmpC(IC)%>" size="77" />
                                    Telephone: <input name="appEmpPhone" type="text" class="textbox" id="appEmpPhone" value="<%=appEmpPhone(IC)%>" size="23" /></td>
                              </tr>
                              <tr>
                                    <td>Address: <input name="appEmpAdd" type="text" class="textbox" id="appEmpAdd" value="<%=appEmpAdd(IC)%>" size="75" />
                                    Dates Of Employment: <input name="appEmpDF" type="text" class="textbox" id="appEmpDF" value="<%=appEmpDF(IC)%>" size="7" /> to <input name="appEmpDT" type="text" class="textbox" id="appEmpDT" value="<%=appEmpDT(IC)%>" size="7" /></td>
                              </tr>
                              <tr>
                                    <td>Supervisor's Name:
                                          <input name="appEmpSup" type="text" class="textbox" id="appEmpSup" value="<%=appEmpSup(IC)%>" size="80" />
                                          Pay $
                                          <input name="appEmpPay" type="text" class="textbox" id="appEmpPay" value="<%=appEmpPay(IC)%>" size="7" />
                                          per
                                          <input name="appEmpRate" type="text" class="textbox" id="appEmpRate" value="<%=appEmpRate(IC)%>" size="7" /></td>
                              </tr>
                              <tr>
                                    <td>Job Title/Duties: <input name="appEmpDuties" type="text" class="textbox" id="appEmpDuties" value="<%=appEmpDuties(IC)%>" size="117" /></td>
                              </tr>
                              <tr>
                                    <td>Reason For Leaving
                                          <input name="appEmpLeft" type="text" class="textbox" id="appEmpLeft" value="<%=appEmpLeft(IC)%>" size="113" /></td>
                              </tr>
                              <tr style="display:none">
                                  <td><a style="padding:5px 0 5px 715px;" href='#' onclick="delRow(this);return false;">Remove Employer</a></td>
                            </tr>
                              <tr>
                                  <td><hr /></td>
                            </tr>
                              <%next%>
            </tbody>
            </table>
What line throws the error?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kevp75

ASKER

doh!
Avatar of kevp75

ASKER

looks like it did it
Avatar of kevp75

ASKER

i'll get back to you with points in a bit, I just want to make sure it definately works...
No rush. Take your time :)