function list_box_add()
{
//'serial_list' is the name of list box
//'serial_number' is a comboBox
//the selected value of comboBox are adding to the list
/**********duplication check block***********/
for (i =0;i=0)
document.form1.serial_list.remove(document.forms["form1"].serial_list.selectedIndex);
else
alert('No Item Selected');
//alert(document.forms["form1"].serial_list.options[1]);
//document.forms["myForm"].state.options[1];
//document.write(document.forms['form1'].serial_list.selectedIndex);
}
JS code for delete row of table
function deleteRow(id)JS code for trim string
{
var row = id.parentNode.parentNode.rowIndex;
var tbody = document.getElementById("table_id").tBodies[0].deleteRow(row);
//'table_id' is the id of the table
}
//calling function should call like this[ onclick="deleteRow(this)"] into button tag
function triim(st,d)//st string & d=1 for killing space inside the string
//d=0 & d=1 both kill leading & trailing space
{
var len = st.length;
var str="";
var i;
var first=0,last=len;
for(i=0;i
{ if(st.charAt(i)!=' ')
{ last=i;
break;
}
}
for(i=first;i<=last;i++) { if(d==1 && st.charAt(i)==' ') {} else str+=st.charAt(i); } return str; }
JS code to add new row in table
function add_row(){
var tbody = document.getElementById("table_id").getElementsByTagName("tbody")[0];
var row = document.createElement("TR");
var cell1 = document.createElement("TD");
cell1.innerHTML = "babu"; //can use some HTML
//var cell2 = document.createElement("TD");
//cell2.innerHTML = "babu"; //can use some HTML
/****** as required cell can b added*********/
row.appendChild(cell1);
//row.appendChild(cell2);
tbody.appendChild(row);
}
No comments:
Post a Comment