superfly404
Technical User
i've built a simple form, where it ask for first name, last name, and phone number. (you can do a max of 9)
When you click the confirm link, in theory, it should take you over to a confirm section (with onClick) where it will confirm all the info you just entered...maybe with some inner html, but i'm unsure what i need to do since the fields are dynamic?
if anyone has any ideas, would love to get feedback
<script>
// add rows
var numRow = 0;
var nwRowId = '';
var tdArray = new Array(3);
function addRow(){
if (numRow<8) {
numRow++;
nwRowId = "r" + numRow;
var tbody = document.getElementById('myTab').getElementsByTagName("TBODY")[0];
var nwRow = document.createElement("TR");
nwRow.setAttribute("id", nwRowId);
for(var k = 0; k < tdArray.length; k++){
var nwTD = document.createElement("TD");
nwRow.appendChild(nwTD);
}
tbody.appendChild(nwRow);
//Now that the new row is intact add HTML
resetHTML();
}
else {
document.getElementById("addlink").innerHTML=' ';
}}
function resetHTML(){
tdArray.length = 0;
var td1HTML = '<input name="last' +numRow+ '" type=text id="last" value="" size="20">';
var td2HTML = '<input name="first' +numRow+ '" type=text id="first" value="" size="20">';
var td3HTML = '<input name="phone' +numRow+ '" type=text id="phone" value="" size="20">';
tdArray = [td1HTML,td2HTML,td3HTML];
var el = document.getElementById(nwRowId).getElementsByTagName('td');
for(j = 0; j < el.length; j++){
el[j].innerHTML = tdArray[j];
}
}
function removeRow()
{
var tbl = document.getElementById('myTab');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}
////// review confirm
function reviewConfirm() {
doConfirm();
var elem = document.getElementById("reviewConfirm");
elem.style.display = "block";
document.getElementById('second').style.display = 'none';
}
function doConfirm() {
document.getElementById("confirmation11").innerHTML=document.getElementById('last').value + ', ' + document.getElementById('first').value;
document.getElementById("confirmation12").innerHTML=document.getElementById("appCode").value;
}
</script>
<h1>Information</h1><br><div id="second">
<table width="550" border="0" cellpadding="0" cellspacing="0" class="cpySmall" id=myTab>
<tbody>
<tr>
<td width="151"><span class="cpySmall">Last name:</span><br>
<input name=last type=text id="last" value="" size="20"></td>
<td width="154"><span class="cpySmall">First name:</span><br>
<input name=first type=text id="first" value="" size="20">
</td>
<td width="245"><span class="cpySmall">Phone number:</span><br>
<input name=phone type=text id="ticket" value="" size="20"></td>
</tr>
</table>
<table width="248" height="28" border="0" cellpadding="0" cellspacing="0" class="cpySmall">
<tr>
<td width="109" id="addlink"><a href="#passengers" onClick="addRow()"><span class="cpySmall">Add passenger</span></a> </td>
<td width="139"><a href="#passengers" onClick="removeRow()"><span class="cpySmall">Remove passenger</span></a> </td>
</tr>
</table>
<p><a href="#" onClick="reviewConfirm()">Confirm</a></p>
</div>
<div id="reviewConfirm" style="display: none;">
<h1>Confirmation</h1><br>
<table width="550" border="0" cellpadding="0" cellspacing="0" id="confirmSet">
<tr valign="top" class="cpyBody">
<td width="50%" height="25" class="cpyHeader2">Passenger Name(s)</td>
<td width="50%" height="25" class="cpyHeader2">Phone Numbers</td>
</tr>
<tr class="cpyBody">
<td height="20" id="confirmation11"> </td>
<td height="20"> </td>
</tr>
</table></div>
thanks
eric
When you click the confirm link, in theory, it should take you over to a confirm section (with onClick) where it will confirm all the info you just entered...maybe with some inner html, but i'm unsure what i need to do since the fields are dynamic?
if anyone has any ideas, would love to get feedback
<script>
// add rows
var numRow = 0;
var nwRowId = '';
var tdArray = new Array(3);
function addRow(){
if (numRow<8) {
numRow++;
nwRowId = "r" + numRow;
var tbody = document.getElementById('myTab').getElementsByTagName("TBODY")[0];
var nwRow = document.createElement("TR");
nwRow.setAttribute("id", nwRowId);
for(var k = 0; k < tdArray.length; k++){
var nwTD = document.createElement("TD");
nwRow.appendChild(nwTD);
}
tbody.appendChild(nwRow);
//Now that the new row is intact add HTML
resetHTML();
}
else {
document.getElementById("addlink").innerHTML=' ';
}}
function resetHTML(){
tdArray.length = 0;
var td1HTML = '<input name="last' +numRow+ '" type=text id="last" value="" size="20">';
var td2HTML = '<input name="first' +numRow+ '" type=text id="first" value="" size="20">';
var td3HTML = '<input name="phone' +numRow+ '" type=text id="phone" value="" size="20">';
tdArray = [td1HTML,td2HTML,td3HTML];
var el = document.getElementById(nwRowId).getElementsByTagName('td');
for(j = 0; j < el.length; j++){
el[j].innerHTML = tdArray[j];
}
}
function removeRow()
{
var tbl = document.getElementById('myTab');
var lastRow = tbl.rows.length;
if (lastRow > 2) tbl.deleteRow(lastRow - 1);
}
////// review confirm
function reviewConfirm() {
doConfirm();
var elem = document.getElementById("reviewConfirm");
elem.style.display = "block";
document.getElementById('second').style.display = 'none';
}
function doConfirm() {
document.getElementById("confirmation11").innerHTML=document.getElementById('last').value + ', ' + document.getElementById('first').value;
document.getElementById("confirmation12").innerHTML=document.getElementById("appCode").value;
}
</script>
<h1>Information</h1><br><div id="second">
<table width="550" border="0" cellpadding="0" cellspacing="0" class="cpySmall" id=myTab>
<tbody>
<tr>
<td width="151"><span class="cpySmall">Last name:</span><br>
<input name=last type=text id="last" value="" size="20"></td>
<td width="154"><span class="cpySmall">First name:</span><br>
<input name=first type=text id="first" value="" size="20">
</td>
<td width="245"><span class="cpySmall">Phone number:</span><br>
<input name=phone type=text id="ticket" value="" size="20"></td>
</tr>
</table>
<table width="248" height="28" border="0" cellpadding="0" cellspacing="0" class="cpySmall">
<tr>
<td width="109" id="addlink"><a href="#passengers" onClick="addRow()"><span class="cpySmall">Add passenger</span></a> </td>
<td width="139"><a href="#passengers" onClick="removeRow()"><span class="cpySmall">Remove passenger</span></a> </td>
</tr>
</table>
<p><a href="#" onClick="reviewConfirm()">Confirm</a></p>
</div>
<div id="reviewConfirm" style="display: none;">
<h1>Confirmation</h1><br>
<table width="550" border="0" cellpadding="0" cellspacing="0" id="confirmSet">
<tr valign="top" class="cpyBody">
<td width="50%" height="25" class="cpyHeader2">Passenger Name(s)</td>
<td width="50%" height="25" class="cpyHeader2">Phone Numbers</td>
</tr>
<tr class="cpyBody">
<td height="20" id="confirmation11"> </td>
<td height="20"> </td>
</tr>
</table></div>
thanks
eric