如何使用Struts 1.2.9标签

时间:2016-01-08 01:27:00

标签: javascript struts-1

我正在使用Struts版本1.2.9。 我需要使用JavaScript动态地向表中添加行,这样可以正常工作。

看起来像:

function addRow(tableID) {

   var table = document.getElementById(tableID); 

   rowCount += 1;      

   if(rowCount <= 5){
    var row = table.insertRow(3);   
    var col1html = "<label for='incomecategory'>Other Income:</label>";  
    var col2html = "<select id='incomecategory' name='income_category'><option value='' selected>Please Select</option><option value='rent'>Rent</option><option value='interestanddividends'>Interest and Dividends</option><option value='governmentbenefits'>Government Benefits</option><option value='other'>Other</option></select>";
    var col3html = "$<input type='text' name='incomevalue' id='incomevalue'/>";
    var col4html = "<select id='incomefrequency' name='income_frequency'><optgroup label='Per'><option value='perweek'>Per Week</option><option value='perfortnight'>Per Fortnight</option><option value='peryear'>Per Month</option><option value='peryear'>Per Year</option><option value='' selected>Per</option></select>";
    var col5html = "<input type='button' value='X' onclick='removeRow(this)'/>"

    var col1 = row.insertCell(0); col1.innerHTML=col1html;
    var col2 = row.insertCell(1); col2.innerHTML=col2html;
    var col3 = row.insertCell(2); col3.innerHTML=col3html;
    var col4 = row.insertCell(3); col4.innerHTML=col4html;
    var col5 = row.insertCell(4); col5.innerHTML=col5html;

   }else{

       alert('Reached maximum no of rows');
   }  

}     

如果你仔细看,我已经硬编码了所有HTML标签来构建一行,但我想在创建行时使用struts标签。

0 个答案:

没有答案