kevp75
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...)
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...)
@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
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
ASKER
i have mini-me today, I will post code later on
hahahah sure....
CHEERS...
CHEERS...
ASKER
sorry for the wait folks....here's my code:
function delRow(oThis)
{
var index = oThis.parentNode.parentNod e.rowIndex ;
var table = document.getElementById('e mpTbl');
var tr;
var i;
for (i = 0 ; i < 7 ; i++)
{
table.deleteRow(index - i);
}
}
function addRow()
{
var table = document.getElementById('e mpTbl');
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(o Destinaion TR.cells.l ength);
oDestinaionCell.innerHTML = oSourceTR.cells[i].innerHT ML;
inputs = oDestinaionCell.getElement sByTagName ("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);retu rn false;">Remove Employer</a></td>
</tr>
<tr>
<td><hr /></td>
</tr>
</tbody>
</table> </td>
</tr>
function delRow(oThis)
{
var index = oThis.parentNode.parentNod
var table = document.getElementById('e
var tr;
var i;
for (i = 0 ; i < 7 ; i++)
{
table.deleteRow(index - i);
}
}
function addRow()
{
var table = document.getElementById('e
var tbody = table.getElementsByTagName
var tr;
var i;
for (i = 0 ; i < 7 ; i++)
{
tr = table.insertRow(table.rows
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(o
oDestinaionCell.innerHTML = oSourceTR.cells[i].innerHT
inputs = oDestinaionCell.getElement
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);retu
</tr>
<tr>
<td><hr /></td>
</tr>
</tbody>
</table> </td>
</tr>
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("ap pEmpXXXX") %>, however it is pointless, since:
A) It's a comma-delimited list
b) The extra section(s) disappear anyways...
I know I need to put in value="<%=request.form("ap
A) It's a comma-delimited list
b) The extra section(s) disappear anyways...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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("appEmp C"), ",")
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);retu rn false;">Remove Employer</a></td>
</tr>
<tr>
<td><hr /></td>
</tr>
<%next%>
</tbody>
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("appEmp
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%>
</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%>"
</tr>
<tr>
<td>Job Title/Duties: <input name="appEmpDuties" type="text" class="textbox" id="appEmpDuties" value="<%=appEmpDuties&IC%
</tr>
<tr>
<td>Reason For Leaving
<input name="appEmpLeft" type="text" class="textbox" id="appEmpLeft" value="<%=appEmpLeft&IC%>"
</tr>
<tr style="display:none">
<td><a style="padding:5px 0 5px 715px;" href='#' onclick="delRow(this);retu
</tr>
<tr>
<td><hr /></td>
</tr>
<%next%>
</tbody>
ASKER
and..one thing I noticed...when you first load the page, there are 1's in every field in this section
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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'
<%
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
doh..missed the initial
arrEmpC = Split(" ", ","), put that in, and it fixed the lbound
but the type mismatch error on 'appEmpC' still shows
arrEmpC = Split(" ", ","), put that in, and it fixed the lbound
but the type mismatch error on 'appEmpC' still shows
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("appEmp C"), ",")
else
arrEmpC = Split(" ", ",")
end if
If (request.form("appEmpPhone ") <> "") then
arrEmpPhone = Split(request.form("appEmp Phone"), ",")
else
arrEmpPhone = Split(" ", ",")
end if
If (request.form("appEmpAdd") <> "") then
arrEmpAdd = Split(request.form("appEmp Add"), ",")
else
arrEmpAdd = Split(" ", ",")
end if
If (request.form("appEmpDF") <> "") then
arrEmpDF = Split(request.form("appEmp DF"), ",")
else
arrEmpDF = Split(" ", ",")
end if
If (request.form("appEmpDT") <> "") then
arrEmpDT = Split(request.form("appEmp DT"), ",")
else
arrEmpDT = Split(" ", ",")
end if
If (request.form("appEmpSup") <> "") then
arrEmpSup = Split(request.form("appEmp Sup"), ",")
else
arrEmpSup = Split(" ", ",")
end if
If (request.form("appEmpPay") <> "") then
arrEmpPay = Split(request.form("appEmp Pay"), ",")
else
arrEmpPay = Split(" ", ",")
end if
If (request.form("appEmpRate" ) <> "") then
arrEmpRate = Split(request.form("appEmp Rate"), ",")
else
arrEmpRate = Split(" ", ",")
end if
If (request.form("appEmpDutie s") <> "") then
arrEmpDuties = Split(request.form("appEmp Duties"), ",")
else
arrEmpDuties = Split(" ", ",")
end if
If (request.form("appEmpLeft" ) <> "") then
arrEmpLeft = Split(request.form("appEmp Left"), ",")
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);retu rn false;">Remove Employer</a></td>
</tr>
<tr>
<td><hr /></td>
</tr>
<%next%>
</tbody>
</table>
<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("appEmp
else
arrEmpC = Split(" ", ",")
end if
If (request.form("appEmpPhone
arrEmpPhone = Split(request.form("appEmp
else
arrEmpPhone = Split(" ", ",")
end if
If (request.form("appEmpAdd")
arrEmpAdd = Split(request.form("appEmp
else
arrEmpAdd = Split(" ", ",")
end if
If (request.form("appEmpDF") <> "") then
arrEmpDF = Split(request.form("appEmp
else
arrEmpDF = Split(" ", ",")
end if
If (request.form("appEmpDT") <> "") then
arrEmpDT = Split(request.form("appEmp
else
arrEmpDT = Split(" ", ",")
end if
If (request.form("appEmpSup")
arrEmpSup = Split(request.form("appEmp
else
arrEmpSup = Split(" ", ",")
end if
If (request.form("appEmpPay")
arrEmpPay = Split(request.form("appEmp
else
arrEmpPay = Split(" ", ",")
end if
If (request.form("appEmpRate"
arrEmpRate = Split(request.form("appEmp
else
arrEmpRate = Split(" ", ",")
end if
If (request.form("appEmpDutie
arrEmpDuties = Split(request.form("appEmp
else
arrEmpDuties = Split(" ", ",")
end if
If (request.form("appEmpLeft"
arrEmpLeft = Split(request.form("appEmp
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)%
</tr>
<tr>
<td>Address: <input name="appEmpAdd" type="text" class="textbox" id="appEmpAdd" value="<%=appEmpAdd(IC)%>"
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)%>"
Pay $
<input name="appEmpPay" type="text" class="textbox" id="appEmpPay" value="<%=appEmpPay(IC)%>"
per
<input name="appEmpRate" type="text" class="textbox" id="appEmpRate" value="<%=appEmpRate(IC)%>
</tr>
<tr>
<td>Job Title/Duties: <input name="appEmpDuties" type="text" class="textbox" id="appEmpDuties" value="<%=appEmpDuties(IC)
</tr>
<tr>
<td>Reason For Leaving
<input name="appEmpLeft" type="text" class="textbox" id="appEmpLeft" value="<%=appEmpLeft(IC)%>
</tr>
<tr style="display:none">
<td><a style="padding:5px 0 5px 715px;" href='#' onclick="delRow(this);retu
</tr>
<tr>
<td><hr /></td>
</tr>
<%next%>
</tbody>
</table>
What line throws the error?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
doh!
ASKER
looks like it did it
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 :)
Can you tell where and why you need to assign the value -- (Value="<%=theField%>" ) ? And where do these value come from?