将数据加载到动态行Cell

时间:2015-10-12 10:42:15

标签: javascript php mysql

我正在尝试将MySQL表字段数据加载到动态插入行字段单元格。但是如果没有Ajax,我不知道如何做到这一点。您的建议可能有助于完成此任务。



var cellLeft = row.insertCell(0);
        var el = document.createElement('input');
		el.type = 'text';
        el.name = 'SL' + iteration;
        el.id = 'SL' + iteration;
        el.size = 5;
		cellLeft.appendChild(el);

       // var textNode = document.createTextNode(iteration);
        //cellLeft.appendChild(textNode);

        // right cell
		 var cellRight = row.insertCell(1);
        var eel = document.createElement('input');
		eel.type = 'text';
        eel.name = 'STYLE' + iteration;
        eel.id = 'STYLE' + iteration;
        eel.size = 15
        cellRight.appendChild(eel);
		
		var cellRight2 = row.insertCell(2);
        var eel = document.createElement('input');
		eel.type = 'text';
        eel.name = 'PROD_REF' + iteration;
        eel.id = 'PROD_REF' + iteration;
		eel.size = 15
        cellRight2.appendChild(eel);
		
		
		var cellRight3 = row.insertCell(3);
        var eel = document.createElement('input');
		eel.type = 'text';
        eel.name = 'OUR_REF' + iteration;
        eel.id = 'OUR_REF' + iteration;
        eel.size = 15
        cellRight3.appendChild(eel);
		
        var cellRight4 = row.insertCell(4);
        var eel = document.createElement('textarea');
		eel.type = 'text';
        eel.name = 'ITEM_DESC' + iteration;
        eel.id = 'ITEM_DESC' + iteration;
        eel.size = 10
        cellRight4.appendChild(eel);

        var cellRight5 = row.insertCell(5);
        var el = document.createElement('input');
        el.type = 'text';
        el.name = 'QTY' + iteration;
        el.id = 'QTY' + iteration;
        el.setAttribute('class', 'QTY');
        el.onblur = function() { productcalc(); };
        el.class = 'QTY'
        el.size = 10;
        cellRight5.appendChild(el);

        var cellRight6 = row.insertCell(6);
        var el = document.createElement('input');
        el.type = 'text';
        el.setAttribute('class', 'PRICE');
        el.onblur = function() { productcalc(); };
        el.name = 'PRICE' + iteration;
        el.id = 'PRICE' + iteration;
        el.size = 10;
        cellRight6.appendChild(el);

        var cellRight7 = row.insertCell(7);
        var el = document.createElement('input');
        el.type = 'text';
        el.name = 'AMOUNT' + iteration;
        el.setAttribute('class', 'AMOUNT');
        el.onblur = function() { productcalc(); };
        el.class = 'AMOUNT'
        el.id = 'AMOUNT';
        el.size = 10;
        cellRight7.appendChild(el);




这是我的第一行PHP代码。然后想插入动态行



<tbody>
            <tr>
           
                <td><input readonly name="SL"id="SL" value="1" size='5' /></td>
                <td><input type="text" name="STYLE" class="STYLE" id="STYLE" size='15' /></td>
                <td><?php

mysql_connect('localhost', 'root', '');
mysql_select_db('aaa');

$sql = "SELECT Code FROM label_entry ORDER BY Code ASC";
$result = mysql_query($sql);

echo "<select name='PROD_REF' class='PROD_REF' id='PROD_REF' STYLE='width: 120px'>";
while ($row = mysql_fetch_array($result)) {
    echo "<option value='" . $row['Code'] . "'>" . $row['Code'] . "</option>";
} 
echo "</select>";

?></td>
                 <td><input type="text" name="OUR_REF" class="OUR_REF" id="OUR_REF" size='15' /></td>
                
                <td><textarea name="ITEM_DESC" id="ITEM_DESC" cols="20" rows="1" maxlength="300"></textarea></td>
                <td><input type="text" name="QTY" class="QTY" id="QTY" onBlur="productcalc()" size='10' /></td>
                <td>
                <input type="text" name="PRICE" class="PRICE" id="PRICE" onBlur="productcalc()" size='10' />
                    
                </td>
                <td><input type="text" name="AMOUNT" class="AMOUNT" onBlur="productcalc()" id="AMOUNT" size='10' /></td>
                               
            </tr>
        </tbody>
&#13;
&#13;
&#13;

0 个答案:

没有答案