JavaScript Method by which we can find out same name textfield data

Hi,I m using three text box in jsp with same name,i want to use javascript to show message box in that it will display all value of text field, important ting is that all textfield having same name.waiting for u r reply,Vikas
[260 byte] By [vic.guptaa] at [2007-11-27 4:32:01]
# 1

try this: loop each controls

form = document.forms[0];

myText = "";

for (var c = 0; c < form.elements.length; c++){

if (form.elements[c].type == 'textbox'){

if(form.elements[c].value != null){

myText = myText+form.elements[c].value + ",";

}

}

}

skp71a at 2007-7-12 9:41:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

This isn't a Java question. Wrong forum. JavaScript != Java.

Use document.getElementsByName.

<html>

<head>

<script>

function showContents(fieldName)

{

var allTheBoxes = document.getElementsByName(fieldName);

if ( allTheBoxes == null )

return;

for ( var boxCount = 0; boxCount < allTheBoxes.length; boxCount++ )

{

alert("Value of textfield " + boxCount + ". : " + allTheBoxes[boxCount].value );

}

}

</script>

</head>

<body>

<table>

<tr>

<td>

<input type="text" name="namedBox" value="" />

</td>

</tr>

<tr>

<td>

<input type="text" name="namedBox" value="" />

</td>

</tr>

<tr>

<td>

<input type="text" name="namedBox" value="" />

</td>

</tr>

<tr>

<td>

<input type="text" name="namedBox" value="" />

</td>

</tr>

<tr>

<td>

<input type="text" name="namedBox" value="" />

</td>

</tr>

<tr>

<td>

<input type="text" name="namedBox" value="" />

</td>

</tr>

<tr>

<td>

<input type="button" name="checkFunction" value="Click Me" onclick="showContents('namedBox');" />

</td>

</tr>

</table>

</body>

</html>

nogoodatcodinga at 2007-7-12 9:41:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Hi,Thanks a lot,Code is working.What abot Nogoodatcoding...........?its good
vic.guptaa at 2007-7-12 9:41:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...