...

View Full Version : Accessing controls inside a table



km99
08-09-2006, 05:55 PM
Hi,

I have a table on which there are a number of cells. some cells contain input boxes that allow users to enter various information. However I need to know how to access the information contained within each cell to allow me to compare it to some other information. Would anyone be able to tell me if this is possible and how I would go about it.

Thanks in advance
Kenny

vwphillips
08-09-2006, 08:04 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<title></title>
<script language="JavaScript" type="text/javascript">
<!--

function zxcFndCell(){
var zxcevt=window.event||arguments.callee.caller.arguments[0];
var zxcobj=zxcEventObj(zxcevt);
while (zxcobj.parentNode){
if (zxcobj.tagName=='TD'){ break; }
zxcobj=zxcobj.parentNode;
}
var zxcips=zxcobj.getElementsByTagName('INPUT');
for (var zxc0=0;zxc0<zxcips.length;zxc0++){
if (zxcips[zxc0].type=='text'){
alert(zxcips[zxc0].value);
}
}

}

function zxcEventObj(zxce){
if (!zxce) var zxce=window.event;
zxce.cancelBubble=true;
if (zxce.stopPropagation) zxce.stopPropagation();
if (zxce.target) zxceobj=zxce.target;
else if (zxce.srcElement) zxceobj=zxce.srcElement;
if (zxceobj.nodeType==3) zxceobj=zxceobj.parentNode;
return zxceobj;
}



//-->
</script>

</head>

<body>
<table border="1" onclick="zxcFndCell();">
<tr>
<td><input name="" value="123" ></td>
<td><input name="" value="1234" ></td>
</tr>
<tr>
<td><input name="" value="12345" ></td>
<td><input name="" value="123456" ></td>
</tr>
</table>
</body>

</html>

km99
08-10-2006, 01:11 PM
cheers!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum