compu17053
05-26-2004, 02:51 PM
Hi
The script only returns whatever is written in the texbox
Can anybody help me in this
whereas when i click the 3rd checkbox the string returned should be s3,s3Name,s3text
When i enter data "222" in the 2nd rows textbox and click the 2 & 3rd checkbox the string returned should be
s2,s2Name,22|s3,s3Name,s3Text in the Output textbox
<script>
function getChecked(theForm)
{
str = ""
for (i=0;i<theForm.elements.length;i++)
{
if (theForm.elements[i].type=='checkbox' && theForm.elements[i].checked)
{
str += "|"+theForm.elements["input"+theForm.elements[i].value].value
}
}
if (str) return str.substring(1); // remove leading '|'
else return ""
}
</script>
<form>
<table border =1>
<tr>
<td>Select</td>
<td>Name</td>
<td>Description</td>
<td>Text</td>
</tr>
<tr>
<td><input type="checkbox" value="1" onClick="this.form.output.value=getChecked(this.form)"
value="s1,S1Name"></td>
<td>s1</td>
<td>S1Name</td>
<td><input type="text" name="input1" value=""></td>
</tr>
<tr>
<td><input type="checkbox" value="2" onClick="this.form.output.value=getChecked(this.form)"
value="s2,S2Name"></td>
<td>s2</td>
<td>S2Name</td>
<td><input type="text" name="input2" value=""></td>
</tr>
<tr>
<td><input type="checkbox" value="3" onClick="this.form.output.value=getChecked(this.form)"
value="s3,S3Name"></td>
<td>s3</td>
<td>S3Name</td>
<td>S3Text</td>
</tr>
</table>
Output:<input type="text" name="output" value="">
</form>
The script only returns whatever is written in the texbox
Can anybody help me in this
whereas when i click the 3rd checkbox the string returned should be s3,s3Name,s3text
When i enter data "222" in the 2nd rows textbox and click the 2 & 3rd checkbox the string returned should be
s2,s2Name,22|s3,s3Name,s3Text in the Output textbox
<script>
function getChecked(theForm)
{
str = ""
for (i=0;i<theForm.elements.length;i++)
{
if (theForm.elements[i].type=='checkbox' && theForm.elements[i].checked)
{
str += "|"+theForm.elements["input"+theForm.elements[i].value].value
}
}
if (str) return str.substring(1); // remove leading '|'
else return ""
}
</script>
<form>
<table border =1>
<tr>
<td>Select</td>
<td>Name</td>
<td>Description</td>
<td>Text</td>
</tr>
<tr>
<td><input type="checkbox" value="1" onClick="this.form.output.value=getChecked(this.form)"
value="s1,S1Name"></td>
<td>s1</td>
<td>S1Name</td>
<td><input type="text" name="input1" value=""></td>
</tr>
<tr>
<td><input type="checkbox" value="2" onClick="this.form.output.value=getChecked(this.form)"
value="s2,S2Name"></td>
<td>s2</td>
<td>S2Name</td>
<td><input type="text" name="input2" value=""></td>
</tr>
<tr>
<td><input type="checkbox" value="3" onClick="this.form.output.value=getChecked(this.form)"
value="s3,S3Name"></td>
<td>s3</td>
<td>S3Name</td>
<td>S3Text</td>
</tr>
</table>
Output:<input type="text" name="output" value="">
</form>