Advertisement

09.30.2008 at 08:03AM PDT, ID: 23774856
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.1

Inserting dynamic rows between dynamic rows using javascript

Asked by Isotropes in JavaScript

Tags: ,

Hi i jus need to add dynamic rows between the rows which are created onclick of "addLocation" button. The concept is sites can have many location, locations can have many products and products can have many fees. please let me if u have any doubts !. Do reply soonStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dynamic Table</title>
<script language="javascript">
function addSite()
{
 
	alert("ADD SITE ");
	var myTable = document.getElementById("myTable");
	var newTR = document.createElement("tr");
	var newName1 = document.createElement("td");
	var newName2 = document.createElement("td");
	var newName3 = document.createElement("td");
	var newName4 = document.createElement("td");
	var newName5 = document.createElement("td");
	var newName6 = document.createElement("td");
	var newName7 = document.createElement("td");
	var newName8 = document.createElement("td");
	var newName9 = document.createElement("td");
	var newName10 = document.createElement("td");
	var newName11 = document.createElement("td");
	
	newName1.innerHTML="<input type='text' name='dynamicSite'>";
	newName2.innerHTML="<a href='resumepage.html'>Site Details</a>";
	newName3.innerHTML="<input type='text' name='dynamicLocation'>";
	newName4.innerHTML="<input type='button' name='dynamicLocationPlus' value=' addLocation ' onclick='addLocation(this.parentNode.parentNode.rowIndex)'>";
	newName5.innerHTML="<input type='text' name='dynamicProduct'>";
	newName6.innerHTML="<input type='button' name='dynamicProductLookup' value=' ^ '>";
	newName7.innerHTML="<input type='button' name='dynamicProductPlus' value=' addProduct ' onclick='addProduct(this.parentNode.parentNode.rowIndex)'>";
	newName8.innerHTML="<select name='dynamicFee'><option selected='selected'>Setup Fee</option><option>Training Fee</option><option>Misc Fee</option></select>";
	newName9.innerHTML="<input type='button' name='dynamicFeePlus' value=' addFee ' onclick='addFee(this.parentNode.parentNode.rowIndex)'>";
	newName10.innerHTML="<input type='button' name='dynamicFeeSetup' value=' FeeSetup '>";
	newName11.innerHTML="<input type='button'  value=' deleteRow ' onclick='deleteRow(this.parentNode.parentNode.rowIndex)'/>";
 
	newTR.appendChild(newName1);
	newTR.appendChild(newName2);
	newTR.appendChild(newName3);
	newTR.appendChild(newName4);
	newTR.appendChild(newName5);
	newTR.appendChild(newName6);
	newTR.appendChild(newName7);
	newTR.appendChild(newName8);
	newTR.appendChild(newName9);
	newTR.appendChild(newName10);
	newTR.appendChild(newName11);
	myTable.appendChild(newTR);
}
 
function addLocation(i){
 
        alert("ADD LOCATION " + i);
        var myTable = document.getElementById("myTable");
        var newTR = document.createElement("tr");
        var newName1 = document.createElement("td");
        var newName2 = document.createElement("td");
        var newName3 = document.createElement("td");
        var newName4 = document.createElement("td");
        var newName5 = document.createElement("td");
        var newName6 = document.createElement("td");
        var newName7 = document.createElement("td");
        var newName8 = document.createElement("td");
		var newName9 = document.createElement("td");
		var newName10 = document.createElement("td");
		var newName11 = document.createElement("td");
 
		newName1.innerHTML="<input type='hidden'>"
		newName2.innerHTML="<input type='hidden'>"
        newName3.innerHTML="<input type='text' name='dynamicLocationLocation'>";
		newName4.innerHTML="<input type='hidden'>"
        newName5.innerHTML="<input type='text' name='dynamicLocationProduct'>";
        newName6.innerHTML="<input type='button' name=' ' value=' ^ '>";
        newName7.innerHTML="<input type='button' name='dynamicLocationProductPlus' value=' addProduct ' onclick='addProduct(this.parentNode.parentNode.rowIndex)' >";
        newName8.innerHTML="<select name='dynamicLocationFee'><option selected='selected'>Setup Fee</option><option>Training Fee</option><option>Misc Fee</option></select>";
        newName9.innerHTML="<input type='button' name='dynamicLocationFeePlus' value=' addFee ' onclick='addFee(this.parentNode.parentNode.rowIndex)'>";
        newName10.innerHTML="<input type='button' name='dynamicLocationFeeSetup' value=' FeeSetup '>";
        newName11.innerHTML="<input type='button'  value=' deleteRow ' onclick='deleteRow(this.parentNode.parentNode.rowIndex)'/>";
      
        newTR.appendChild(newName1);
        newTR.appendChild(newName2);
        newTR.appendChild(newName3);
        newTR.appendChild(newName4);
        newTR.appendChild(newName5);
        newTR.appendChild(newName6);
        newTR.appendChild(newName7);
        newTR.appendChild(newName8);
		newTR.appendChild(newName9);
        newTR.appendChild(newName10);
		newTR.appendChild(newName11);
        myTable.rows(i).appendChild(newTR);
}
 
 function addProduct(i){
 
        alert("ADD PRODUCT " + i);
        var myTable = document.getElementById("myTable");
 
		var newTR = document.createElement("tr");
        var newName1 = document.createElement("td");
        var newName2 = document.createElement("td");
        var newName3 = document.createElement("td");
        var newName4 = document.createElement("td");
        var newName5 = document.createElement("td");
        var newName6 = document.createElement("td");
		var newName7 = document.createElement("td");
		var newName8 = document.createElement("td");
		var newName9 = document.createElement("td");
		var newName10 = document.createElement("td");
		var newName11 = document.createElement("td");
 
        newName1.innerHTML="<input type='hidden'>"
		newName2.innerHTML="<input type='hidden'>"
		newName3.innerHTML="<input type='hidden'>"
		newName4.innerHTML="<input type='hidden'>"
		newName5.innerHTML="<input type='hidden'>"
        newName6.innerHTML="<input type='text' name='dynamicLocationProduct'>";
        newName7.innerHTML="<input type='button' name=' ' value=' ^ '>";
        newName8.innerHTML="<select name='dynamicLocationFee'><option selected='selected'>Setup Fee</option><option>Training Fee</option><option>Misc Fee</option></select>";
        newName9.innerHTML="<input type='button' name='dynamicProductFeePlus' value=' addFee ' onclick='addFee(this.parentNode.parentNode.rowIndex)'>";
        newName10.innerHTML="<input type='button' name='dynamicProductFeeSetup' value=' FeeSetup '>";
        newName11.innerHTML="<input type='button'  value=' deleteRow ' onclick='deleteRow(this.parentNode.parentNode.rowIndex)'/>";
 
        newTR.appendChild(newName1);
        newTR.appendChild(newName2);
        newTR.appendChild(newName3);
        newTR.appendChild(newName4);
        newTR.appendChild(newName5);
        newTR.appendChild(newName6);
		newTR.appendChild(newName7);
        newTR.appendChild(newName8);
        newTR.appendChild(newName9);
        newTR.appendChild(newName10);
        newTR.appendChild(newName11);
        myTable.rows(i).appendChild(newTR);
}
 
 function addFee(i){
 
        alert("ADD FEE " + i);
        var myTable = document.getElementById("myTable");
        var newTR = document.createElement("tr");
        var newName1 = document.createElement("td");
        var newName2 = document.createElement("td");
        var newName3 = document.createElement("td");
		var newName4 = document.createElement("td");
        var newName5 = document.createElement("td");
        var newName6 = document.createElement("td");
		var newName7 = document.createElement("td");
		var newName8 = document.createElement("td");
		var newName9 = document.createElement("td");
		var newName10 = document.createElement("td");
		var newName11 = document.createElement("td");
 
 		newName1.innerHTML="<input type='hidden'>"
		newName2.innerHTML="<input type='hidden'>"
		newName3.innerHTML="<input type='hidden'>"
        newName4.innerHTML="<input type='hidden'>"
		newName5.innerHTML="<input type='hidden'>"
		newName6.innerHTML="<input type='hidden'>"
		newName7.innerHTML="<input type='hidden'>"
		newName8.innerHTML="<input type='hidden'>"
        newName9.innerHTML="<select name='dynamicLocationFee'><option selected='selected'>Setup Fee</option><option>Training Fee</option><option>Misc Fee</option></select>";
        newName10.innerHTML="<input type='button' name='dynamicLocationFeeSetup' value=' FeeSetup '>";
        newName11.innerHTML="<input type='button'  value=' deleteRow ' onclick='deleteRow(this.parentNode.parentNode.rowIndex)'/>";
 
        newTR.appendChild(newName1);
        newTR.appendChild(newName2);
        newTR.appendChild(newName3);
		newTR.appendChild(newName4);
        newTR.appendChild(newName5);
        newTR.appendChild(newName6);
		newTR.appendChild(newName7);
        newTR.appendChild(newName8);
        newTR.appendChild(newName9);
        newTR.appendChild(newName10);
        newTR.appendChild(newName11);
        myTable.rows(i).appendChild(newTR);
}
 
function deleteRow(i){
	alert(i);
   document.getElementById('myTable').deleteRow(i);
}
 
function validate(){
	
	alert("Submit");
}
</script>
</head>
<body>
 
<form name="form">
<table align="right">
	<tr>
		<td><input type="button" value=" addRow " onClick="addSite()"></td>
	</tr>
</table>
<br>
<table>
<tbody id='myTable'>
	<tr>
		<td><input type="text" name=site></td>
		<td><a href ="javascript:void(0)" onclick="window.open('login.html')">Site Details</a></td>
		<td><input type="text" name=location></td>
		<td><input type="button" name="locationPlus" value=" addLocation " onclick='addLocation(this.parentNode.parentNode.rowIndex)'></td>
		<td><input type="text" name=product></td>
		<td><input type="button" name="productLookup" value=" ^ "></td>
		<td><input type="button" name="productPlus" value=" addProduct " onclick='addProduct(this.parentNode.parentNode.rowIndex)'></td>
		<td><select name="fee" id="fee">
                <option selected="selected">Setup fee</option>
                <option>Training Fee</option>
                <option>Misc Fee</option>
			 </select>
		</td>
			
		<td><input type="button" name="feePlus" value=" addFee " onclick='addFee(this.parentNode.parentNode.rowIndex)'></td>
		<td><input type='button' name="feeSetup" value=" feeSetup " onclick='addFee(this.parentNode.parentNode.rowIndex)'></td>
		<td><input type="button"  value=" deleteRow " onclick='deleteRow(this.parentNode.parentNode.rowIndex)'/></td>
	</tr>
 
</tbody>
</table>
<br>
<table align="center">
	<tr>
		<td>
			<input type="submit" value=" Submit " onclick="validate()">
		</td>
	</tr>
</table>
</form>
</body>
</html>
 
 
[+][-]10.08.2008 at 07:51AM PDT, ID: 22669632

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: JavaScript
Tags: JavaScript, Any IE version
Sign Up Now!
Solution Provided By: alexpercsi
Participating Experts: 1
Solution Grade: B
 
 
[+][-]10.09.2008 at 03:09AM PDT, ID: 22676876

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 - Hierarchy / EE_QW_2_20070628