Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 2nd, 2005, 04:01 AM
darkmunk darkmunk is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 137 darkmunk User rank is Corporal (100 - 500 Reputation Level)darkmunk User rank is Corporal (100 - 500 Reputation Level)darkmunk User rank is Corporal (100 - 500 Reputation Level)darkmunk User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 16 h 16 m 11 sec
Reputation Power: 6
So close! but no cigar - script to find last field in each row

Please help! I'm sure this is nearly there! The alert should output the contents of an array, which should be the value of the last text field in each row of a dynamic table. There must be an easier way to do this.
Here's the test page, Please don't laugh, it is a right dogs dinner I'm sure!
NB:I put the script after the table so the table ID is ready.
Thanks, Mark

<html>
<head></head>
<body>
<input name="Submit" type="submit" onClick="getValue()"; value="value of last field in each row">
<table width="48%" border="0" id="inventory">
<tr bgcolor="#00CC00">
<td width="13%">row 1</td>
<td width="10%"> <input name="textfield" type="text" value="qty" size="5"></td>
<td width="20%">$40.00 </td>
<td width="57%"> <input name="textfield3" type="text" value="0.00" size="30">
</td>
</tr>
<tr>
<td>row 2</td>
<td><input name="textfield4" type="text" value="qty" size="5"></td>
<td>$30.00</td>
<td><input name="textfield6" type="text" value="0.00" size="30"></td>
</tr>
</table>
<script language="JavaScript1.2" type="text/javascript">
<!--
var j=0;
var arrayIncrement=0;
var totalsArray=new Array();
var oTxt = new Array();

function getValue(){
if(document.getElementById) {
var table = document.getElementById('table1'), rows;

if(table && (rows = table.rows)) {
// Add the listener to each row in the table.
for(var i = 0;i<rows.length;++i) {
//rows[i].onclick = showRowNum;
//var oInp = thisrow.
var oInp = this.getElementsByTagName('input');
for(x=0;x<oInp.length;i++){
if(oInp[x].type=='text'){
oTxt[j]=oInp[x];
var lastValue = oTxt[oTxt.length-1].value;
j++;
}
totalsArray[arrayIncrement]=lastValue;
arrayIncrement++;

}
}
}
}

alert(totalsArray);

}
//-->
</script>
</body>
</html>

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > So close! but no cigar - script to find last field in each row


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway