Hi All.......................
I need a help
In my application, I want to add some data and for that, I have to create a row dynamically. I can add multiple such type of rows in the applcation.
For this, I am using JQuery and the code used is...
// ajax call to get allowances
$("#addAllow").click(function() {
var paycomp = $('#Paycomp').val();
alert("=== VAL PAYCOMP ==== "+paycomp);
if(paycomp == null || paycomp == "zz"){
alert("SELECT A PAYCOMP ");
return false;
}else{
showAllow();
}
});
Here showAllow() is an ajax function get the details from DB to display in the JQuery Dialog box. while pressing Submit,
a new row created and selected data will be displayed on the text box.
function showAllowDet(){
alert("===== SHOW ALLOW DET FUNCTION ======= ");
if(dynaId == 0){
$("#empAllowHed").show();
}
var num = $("#divAllow > div").length;
dynaId = new Number(num + 1);
alert("===== dynaId after num ======= "+dynaId);
$("#divAllow").append("<div id='row" + dynaId + "'><tr><td><input type='text' id='allowDesc"+dynaId+"' name='allowDesc"+dynaId+"' size='30'/> <input type='hidden' id='allowCd"+dynaId+"' name='allowCd"+dynaId+"' /> </td><td><input type='text' id='Amount"+dynaId+"' name='Amount"+dynaId+"' size='8'/> </td><td><textarea id='allowRemrk"+dynaId+"' name='allowRemrk"+dynaId+"' rows='2' cols='60' ></textarea> </td><td><input type='button' id='remAllow" + dynaId + "' value='Remove' onclick='removeAllowField(\"#row" + dynaId + "\"); return false;' /> </td><td><input type='button' id='optAllow" + dynaId + "' value='Add Optional' onclick='addOptional(\"#row" + dynaId + "\", \"optional\"); return false;'/> </td></tr></div>");
//alert("======= HTML ===== "+$("#divAllow").html());
$("#empAllowDet").show();
var selctedAllow = $("#Allowcd option:selected").text();
alert("======= SELECTED ALLOWANCE ===== "+selctedAllow);
var selectlAllowCd = $("#Allowcd option:selected").val();
$("#allowDesc"+dynaId).val(selctedAllow);
$("#allowCd"+dynaId).val(selectlAllowCd);
$("#empAllowDilog").dialog( "close");
}
Here I ama dding tow buttons on the row . One is for removing the selected row and the next one is for
creating the same row with another logic.
I want to call ajax function to display the details while clicking on the dynamically created button.
I tried to place my function here and there, inside document.ready and outside also. I am not able to create a new row.
Can you please suggest any way to do it please
Regards,
Joby Joseph