SO fiddle
Test Fiddle mainly for SO Questions
HTML
<script src="https://raw.github.com/dbunic/REDIPS_drag/master/redips-drag-min.js"></script>
<div id="drag">
<table id="Medication" class="medications" summary="This is a summary of my tabular data." caption="Table Title">
<colgroup>
<col width="30" />
<col width="30" />
<col width="100" />
<col width="100" />
<col width="100" />
<col width="30" />
<col width="100" />
</colgroup>
<thead>
<th>Drag</th>
<th class="remove">Del</>
<th>A</th>
<th>+-x/</th>
<th>B</th>
<th>=</th>
<th>C</th>
</thead>
<tbody>
<tr>
<td class="rowhandler">
<div class="drag row">3</div>
</td>
<td class="mark" id="remove"><a class="bbc" href="#"> --- </a></td>
<td>
<!--
<input type="text" class="add" id="A" value="" name="test"/>
-->
</td>
<td class="mark">
<select id="sel_0" style="width: 60px">
<option value="sel">operator</option>
<option value="plus">+</option>
<option value="minus">-</option>
<option value="mulp">x</option>
<option value="div">/</option>
</select>
</td>
<td>
<!--
<input type="text" class="add" id="B" value="" name="test"/>
-->
</td>
...
CSS
h1, h2, h3, h4, h5, h6, body, div.dl, dt, dd, pre, form, input, p, blockquote, th, td
{
margin: 1;
padding: 0;
}
a, a:hover, a:active
{
outline: none;
}
h1, h2, h3, h4, h5, h6
{
font-size: 100%;
font-style: normal;
font-weight: bold;
}
div
{
position: relative;
}
address, caption, cite, code, dfn, em, th, var
{
font-style: normal;
font-weight: normal;
}
table
{
border-collapse: collapse;
border-spacing: 0;
}
img, fieldset
{
border: 0;
}
img
{
-ms-interpolation-mode: bicubic;
}
body
{
font-family: helvetica,arial,sans-serif;
font-size: 16px;
line-height: 1.4em;
color: #54585a;
}
h1, h2, h3, h4, p
{
margin-bottom: 24px;
}
h1
{
font-size: 26px;
}
h2
{
font-size: 21px;
}
a
{
text-decoration: none;
color: #007dba;
}
a:hover
{
text-decoration: underline;
}
a:visited
{
color: #007dba;
}
ol.nav
{
list-style: none;
margin: 0;
padding: 10px 10px 8px 10px;
display: block;
border: 1px solid #cdcdc9;
}
ol.nav li
{
margin: 0 0 2px 0;
padding: 0;
}
ol.nav li a
{
text-decoration: none;
color: #007dba;
display: block;
padding: 5px;
}
ol.nav li a:hover
{
background: #e6e6e3;
}
.header
{
border-bottom: 1px solid #cdcdc9;
padding: 20px 10px;
}
.header a.close
{
position: absolute;
right: 20px;
top: 50px;
background: url(../img/icon-close.png) 0 4px no-repeat;
padding: 0 0 0 20px;
}
.header a.close:hover
{
background-position: 0 -25px;
}
table
{
text-align: left;
width: 100%;
border: 0px;
border-collapse: collapse;
border-spacing: 0px;
margin-bottom: 20px;
}
table thead th
{
background: #eaebe7;
text-align: left;
font-weight: bold;
padding: 10px;
border-right: 1px solid #fff;
font-size: 13px;
}
table tbody th
{
border-bottom: 1px solid #dedfda;
padding: 10px;
width: 150px;
font-size: 13px;
font-weight: bold;
}
table tbody td
{
padding:...
JavaScript
// row incrementer
var count = 1;
var debug1=$("#message");
window.redips = {};
// start =================================================
//$("a#add").click(function() {
$("a#add").on("click", function() {
var tableName = "table#" + this.name;
var $clone = $(tableName + " tr:last").clone();
// assign unique id and name for
$clone.find("a,input,select").each(function() {
$(this).attr({
id: $(this).attr("id") + count,
name: $(this).attr("name") + count,
value: ""
});
});
$clone.find("input[type=button]").each(function() {
$(this).attr({
value: " = "
});
});
$clone.find("select").each(function() {
$(this).attr({
id: "sel_" + count
});
});
//alert($clone.find("input:text").length);
$clone.find("input:text").remove();
// append row to body
$(tableName + " tbody").append($clone);
// remove row associated with the table
$(tableName + " td#remove a").click(function() {
// number of rows; at least one row should always be present
var rows = $(tableName + " tr").length;
if (rows > 2) {
$(this).parent().parent().remove();
}
});
$('select').on('change', function() {
var msg = $(this).val(); // or $(this).val() this.value
var id_tag = $(this).attr("id");
//var cRow = parseInt(id_tag.replace("sel_",""))+100;
var cRow = parseInt(id_tag.substring(4))+0, // current row
but_tag=$("#eq__" + cRow).attr("id");
//var cRow =id_tag.replace("sel_","") + 100;
debug1.html("in~ " + $(this).val() + " : " + id_tag + ":" + cRow+":Button= " + but_tag);
});
count++;
redips.init();
});
// end of start =================================================
$('select').on('change', function() {
...