Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select field populates table?

Status
Not open for further replies.

planeboy747

Technical User
Joined
Jan 11, 2005
Messages
41
Location
US
in this form



how can I get the select field in the beginning of the form (id="nameSet") to populate the appropriate number of order number fields (id="onTable") based on the number selected in id="nameset"?

example, if 4 is selected in "nameSet" then there should be 4 empty Order number fields in "onTable"


here's the code if you want to view here:
-------------------------
----------------------------------------------------------<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Order Request Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<Script Language=JavaScript>

////////////////////////////////
// remove terms and add form //
//////////////////////////////
function authorize()
{
var elem = document.getElementById("second");
elem.style.display = "block";
document.getElementById('accTerms').style.display = 'none';
}
//////////////////////////////////////////////
// create last/first name drop down fields //
////////////////////////////////////////////
function insertRows(isTable){

index = isTable.rows.length;
nextRow = isTable.insertRow(index);
isText1 = nextRow.insertCell(0);
isText2 = nextRow.insertCell(1);
index++;
index = index.toString();
nameStr1 = "Lname"+index;
nameStr2 = "Fname"+index;
txtStr1 = "Last Name "+index+":<br><input name="+nameStr1+" type='text' size='18' maxlength='18'>";
txtStr2 = "First Name "+index+":<br><input name="+nameStr2+" type='text' size='18' maxlength='22'>";
isText1.innerHTML = txtStr1;
isText2.innerHTML = txtStr2;
isText1.width ='25%'
isText2.width = '75%'
}

function adjustRows(isVal,isTable){

currRows = isTable.rows.length;
newRows = isVal;
if (currRows > 0){for (i=0; i<currRows-0; i++){isTable.deleteRow()}}
for (i=0; i<newRows; i++){insertRows(isTable)}
}
/////////////////////////////
// open approval section //
//////////////////////////
function openApprov()
{
var elem = document.getElementById("approvSection");
elem.style.display = "block";
document.getElementById('continue').style.display = 'none';
}
////////////////////////////
// create approval code //
//////////////////////////
var valid = new Array("2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");

function getRandom()
{
var num = Math.floor(Math.random() * valid.length);
return valid[num];
}

function randomString()
{
return "4" + getRandom() + getRandom() + getRandom();
}
</Script>
</head>
<body>
<p>&nbsp;</p>
<div id="accTerms">
<table width="550" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><strong>Acceptance of Terms</strong><br>
These sentences will highlight the acceptance of terms. These sentences will highlight
the acceptance of terms. These sentences will highlight the acceptance of terms.
These sentences will highlight the acceptance of terms.<br>
<br>
These sentences will highlight the acceptance of terms.These sentences will highlight
the acceptance of terms. These sentences will highlight the acceptance of terms.
These sentences will highlight the acceptance of terms. <br>
<br>
These sentences will highlight the acceptance of terms. These sentences will highlight
the acceptance of terms.</td>
</tr>
<tr>
<td align="right"><a href="#start" onClick="authorize(second)">Continue</a></td>
</tr>
</table>
</div>
<br>
<div name="second" id="second" style="display: none;">
<a name="start"></a>Please complete the following form to process your request.<br>
<form name="request">
<strong>*Number of customers: </strong><br>
<select name="select" onchange="adjustRows(this.value,nameSet)">
<option value="1" selected>Select one
<option value="1">1
<option value="2">2
<option value="3">3
<option value="4">4
<option value="5">5
<option value="6">6
<option value="7">7
<option value="8">8
<option value="9">9
</select>
<br>
<br>
<strong>Customer Name(s):</strong><br>
<table width="550" border="0" cellpadding="2" cellspacing="0" id="nameSet" class="cpySmall">
<tr>
<td width="25%" height="18" valign="top" class="cpySmall">*Last Name 1:<br>
<input name="textfield" type="text" size="18">
</td>
<td width="75%" height="18" valign="top" class="cpySmall">First Name 1: <br>
<input name="textfield" type="text" size="18">
</td>
</tr>
</table>
<div id="continue">
<table width="550" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="right"><a href="#" onClick="openApprov(approvSection)">Continue</a></div>
</td>
</tr>
</table>
</div>
<br>
<div id="approvSection" style="display: none;">
<table width="550" border="0" cellspacing="0" cellpadding="0" id="acTable">
<tr>
<td valign="top"><strong>Authorization Code </strong></td>
</tr>
<tr>
<td valign="top">Your autorizaton code for this transaction is
<input name="appCode" type="text" size="4" style="color: #000080; text-transform: uppercase; font-weight: bold; border: 1px solid #FFFFFF" id="approvCode" onLoad="getRandom()">

. Complete your customer purchase orders and add those order numbers to the fields
below and submit. </td>
</tr>
</table>
<br>

<table width="550" border="0" cellspacing="0" cellpadding="0" id="onTable">
<tr>
<td colspan="2"><strong>Order Numbers </strong></td>
</tr>
<tr>
<td width="184">*Order Number 1<br>
<input name="on1" type="text" id="on1" size="18">
</td>
<td width="366">*Order Number 2<br>
<input name="on2" type="text" id="on2" size="18">
</td>
</tr>
<tr>
<td width="184">*Order Number 3<br>
<input name="on3" type="text" id="on3" size="18">
</td>
<td>*Order Number 4<br>
<input name="on4" type="text" id="on4" size="18">
</td>
</tr>
<tr>
<td>*Order Number 5<br>
<input name="on5" type="text" id="on5" size="18">
</td>
<td>*Order Number 6<br>
<input name="on6" type="text" id="on6" size="18">
</td>
</tr>
<tr>
<td>*Order Number 7<br>
<input name="on7" type="text" id="on7" size="18">
</td>
<td>*Order Number 8<br>
<input name="on8" type="text" id="on8" size="18">
</td>
</tr>
<tr>
<td>*Order Number 9<br>
<input name="on9" type="text" id="on9" size="18">
</td>
<td>&nbsp;</td>
</tr>
</table>
</form>
</div>
<br>
</body>
</html>
 
Just add another function like insertRows().

--Chessbot

"In that blessed region of Four Dimensions, shall we linger on the threshold of the Fifth, and not enter therein? Ah, no! [...] Then, yielding to our intellectual onset, the gates of the Sixth Dimension shall fly open; after that a Seventh, and then an Eighth -- --" Flatland, A. Square (E. A. Abbott)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top