A
anirban.anirbanju
hi there,
i've some serious problem to add rows dynamically in a table.
my table contains 5 cell.
| check | from_value | to_value | color_text | color_value |
---------------------------------------------------------------------------------
| | | | |
|
| | | | |
|
----------------------------------------------------------------------------------
1st cell contains checkbox.
2nd....................a textfield.
3rd.....................a textfield.
4th .....................a textfield and a button(colorpicker
button--by clicking i can select color from popup window and the
hexcode is placed in the textfield of this cell and the corresponding
decimal value is placed to the 5th cell's textfield.)
5th cell contains a textfield.
i've done this.the code is ok for my table when it contains a single
row(my table always contains a single row).
when i add rows by clicking addRow button from this page the rows are
added but i can't get the hexvalue and corresponding decimal value the
4th & 5th cell's textfield for the newly added rows.what's happening,
selecting the color from the popup for newly added rows affect the 1st
row's 4th & 5th cell's textfields.
my script is:
---------------------------------------------------------------------------------------------------------------------
function addRow()
{
alert("called addRow");
var totalRow = document.all.colordef_tab.rows.length;
alert("total row:"+totalRow);
var row = document.all.colordef_tab.insertRow();
var cell_1 = row.insertCell();
var cell_2 = row.insertCell();
var cell_3 = row.insertCell();
var cell_4 = row.insertCell();
var cell_5 = row.insertCell();
cell_1.innerHTML = '<input type="checkbox" name="deleteflag"
id="deleteflag" value="">'+
'<input type="hidden" name="frm_colordefid"
value="">';
cell_2.innerHTML = '<input type="text" align="left"
name="frm_fromvalue" value="">';
cell_3.innerHTML = '<input type="text" align="left"
name="frm_tovalue" value="">';
cell_4.innerHTML = '<input type="text" name="frm_colortext"
id="result_ids" value="" readonly >'+
'<input id="button_id" type=button
onClick="ColorChooser(\'button_id\', \'result_ids\',\'value\')"
value="color">';
cell_5.innerHTML = '<input type="text" align="left"
name="frm_colorvalue" id="dest_id" value="" readonly>';
}
and my jsp is:
-------------------------------------------------------------------------------------------------------
<table width="100%" id="colordef_tab" border="1">
<tr class="list">
<td width="5%" align="left" class="style7"
scope="col">Delete</td>
<td width="20%" align="center" class="style7"
scope="col">From Value </td>
<td width="20%" align="center" class="style7" scope="col">To
Value </td>
<td width="30%" align="center" class="style7"
scope="col">Color Text </td>
<td width="22%" align="center" class="style7"
scope="col">Color Value </td>
</tr>
<%
try
{
if(assaycolors.length>0)
{System.out.println("assaycolors length:"+assaycolors.length);
for(int i=0;i<assaycolors.length;i++)
{
%>
<tr>
<td align="left">
<input type="checkbox" name="deleteflag" id="deleteflag"
value="">
<input type="hidden" name="frm_colordefid"
value="<%=assaycolors.getColorDefId().toString()!=null?assaycolors.getColorDefId().toString():""%>">
</td>
<td><input type="text" name="frm_fromvalue"
value="<%=assaycolors.getFromValue().toString()!=null?assaycolors.getFromValue().toString():""%>"></td>
<td><input type="text" name="frm_tovalue"
value="<%=assaycolors.getToValue().toString()!=null?assaycolors.getToValue().toString():""%>"></td>
<td> <input type="text" name="frm_colortext" id="r_id"
value="<%=assaycolors.getColorText()!=null?assaycolors.getColorText():""%>"
readonly>
<input id="b_id" type="button" value="color"
onClick="ColorChooser('b_id', 'r_id')"></td>
<%-- <td><input type="text" name="frm_colortext"
value="<%=assaycolors.getColorText()!=null?assaycolors.getColorText():""%>"></td>
--%>
<td><input type="text" name="frm_colorvalue" id="dest_id"
value="<%=assaycolors.getColorValue().toString()!=null?assaycolors.getColorValue().toString():""%>"
readonly></td>
</tr>
<%
}
}
else
{
%>
<tr>
</td>
<td align="left">
<input type="checkbox" name="deleteflag" id="t_deleteflag"
value="">
<input type="hidden" name="frm_colordefid" value="">
</td>
<td><input type="text" name="frm_fromvalue" value=""></td>
<td><input type="text" name="frm_tovalue" value=""></td>
<%-- <td><input type="text" name="frm_colortext"
value=""></td> --%>
<td> <input type="text" name="frm_colortext" id="result_id"
value="" readonly>
<input id="button_id" type="button" value="color"
onClick="ColorChooser('button_id', 'result_id', 'value')"> </td>
<td><input type="text" name="frm_colorvalue" id="dest_id"
readonly>
</td>
</tr>
<%
}
%>
i've some serious problem to add rows dynamically in a table.
my table contains 5 cell.
| check | from_value | to_value | color_text | color_value |
---------------------------------------------------------------------------------
| | | | |
|
| | | | |
|
----------------------------------------------------------------------------------
1st cell contains checkbox.
2nd....................a textfield.
3rd.....................a textfield.
4th .....................a textfield and a button(colorpicker
button--by clicking i can select color from popup window and the
hexcode is placed in the textfield of this cell and the corresponding
decimal value is placed to the 5th cell's textfield.)
5th cell contains a textfield.
i've done this.the code is ok for my table when it contains a single
row(my table always contains a single row).
when i add rows by clicking addRow button from this page the rows are
added but i can't get the hexvalue and corresponding decimal value the
4th & 5th cell's textfield for the newly added rows.what's happening,
selecting the color from the popup for newly added rows affect the 1st
row's 4th & 5th cell's textfields.
my script is:
---------------------------------------------------------------------------------------------------------------------
function addRow()
{
alert("called addRow");
var totalRow = document.all.colordef_tab.rows.length;
alert("total row:"+totalRow);
var row = document.all.colordef_tab.insertRow();
var cell_1 = row.insertCell();
var cell_2 = row.insertCell();
var cell_3 = row.insertCell();
var cell_4 = row.insertCell();
var cell_5 = row.insertCell();
cell_1.innerHTML = '<input type="checkbox" name="deleteflag"
id="deleteflag" value="">'+
'<input type="hidden" name="frm_colordefid"
value="">';
cell_2.innerHTML = '<input type="text" align="left"
name="frm_fromvalue" value="">';
cell_3.innerHTML = '<input type="text" align="left"
name="frm_tovalue" value="">';
cell_4.innerHTML = '<input type="text" name="frm_colortext"
id="result_ids" value="" readonly >'+
'<input id="button_id" type=button
onClick="ColorChooser(\'button_id\', \'result_ids\',\'value\')"
value="color">';
cell_5.innerHTML = '<input type="text" align="left"
name="frm_colorvalue" id="dest_id" value="" readonly>';
}
and my jsp is:
-------------------------------------------------------------------------------------------------------
<table width="100%" id="colordef_tab" border="1">
<tr class="list">
<td width="5%" align="left" class="style7"
scope="col">Delete</td>
<td width="20%" align="center" class="style7"
scope="col">From Value </td>
<td width="20%" align="center" class="style7" scope="col">To
Value </td>
<td width="30%" align="center" class="style7"
scope="col">Color Text </td>
<td width="22%" align="center" class="style7"
scope="col">Color Value </td>
</tr>
<%
try
{
if(assaycolors.length>0)
{System.out.println("assaycolors length:"+assaycolors.length);
for(int i=0;i<assaycolors.length;i++)
{
%>
<tr>
<td align="left">
<input type="checkbox" name="deleteflag" id="deleteflag"
value="">
<input type="hidden" name="frm_colordefid"
value="<%=assaycolors.getColorDefId().toString()!=null?assaycolors.getColorDefId().toString():""%>">
</td>
<td><input type="text" name="frm_fromvalue"
value="<%=assaycolors.getFromValue().toString()!=null?assaycolors.getFromValue().toString():""%>"></td>
<td><input type="text" name="frm_tovalue"
value="<%=assaycolors.getToValue().toString()!=null?assaycolors.getToValue().toString():""%>"></td>
<td> <input type="text" name="frm_colortext" id="r_id"
value="<%=assaycolors.getColorText()!=null?assaycolors.getColorText():""%>"
readonly>
<input id="b_id" type="button" value="color"
onClick="ColorChooser('b_id', 'r_id')"></td>
<%-- <td><input type="text" name="frm_colortext"
value="<%=assaycolors.getColorText()!=null?assaycolors.getColorText():""%>"></td>
--%>
<td><input type="text" name="frm_colorvalue" id="dest_id"
value="<%=assaycolors.getColorValue().toString()!=null?assaycolors.getColorValue().toString():""%>"
readonly></td>
</tr>
<%
}
}
else
{
%>
<tr>
</td>
<td align="left">
<input type="checkbox" name="deleteflag" id="t_deleteflag"
value="">
<input type="hidden" name="frm_colordefid" value="">
</td>
<td><input type="text" name="frm_fromvalue" value=""></td>
<td><input type="text" name="frm_tovalue" value=""></td>
<%-- <td><input type="text" name="frm_colortext"
value=""></td> --%>
<td> <input type="text" name="frm_colortext" id="result_id"
value="" readonly>
<input id="button_id" type="button" value="color"
onClick="ColorChooser('button_id', 'result_id', 'value')"> </td>
<td><input type="text" name="frm_colorvalue" id="dest_id"
readonly>
</td>
</tr>
<%
}
%>