function addRow(id)

        {   

    var row = $("#rows").val(); 

    var rows=parseInt(row)+1;

        var sendString = "rows="+rows;

        $("#rows").val(rows);   
        $.ajax({
            type: "POST",
            url: "addrow.htm",
            data: sendString,
            success: function(msg){

                    $("#tr_"+row).after(msg);  
                    loadDatePicker();
            }
        });     
}


function deleteRow(id)
{   

    /* var space_number_arr = id.split("_"); */
    var number = id;
    var deletedRows=$("#deletedRows").val();
    deletedRows=deletedRows+number+",";

    document.getElementById("tr_"+number).style.display='none';

    $("#deletedRows").val(deletedRows);

What is your question? If you need help, you need to provide more information and clarity in what the issue is and what you are trying to do.

Hi Jorge,
I got hold of these two functions while doing my project. I dont kno this language well, so I need help to crack this. Will u help me to understand this ?

Ok, so lets see if we can disect this a bit...

function addRow(id){   
    var row = $("#rows").val(); 
    var rows=parseInt(row)+1;
        var sendString = "rows="+rows;
        $("#rows").val(rows);   
        $.ajax({
            type: "POST",
            url: "addrow.htm",
            data: sendString,
            success: function(msg){
                    $("#tr_"+row).after(msg);  
                    loadDatePicker();
            }
        });     
}

function deleteRow(id)
{   
    /* var space_number_arr = id.split("_"); */
    var number = id;
    var deletedRows=$("#deletedRows").val();
    deletedRows=deletedRows+number+",";
    document.getElementById("tr_"+number).style.display='none';
    $("#deletedRows").val(deletedRows);
}

lines 1-15 is the function for addRow(id). This function accepts one parameter, I assume the ID of the element. However, this parameter doesnt seem to be used in this function anywhere.

line 2, you are assinging the value (should be an element of type input) to the variable called row.

line 3, you are trying to parse an integer value out of the variable row.

line 4, you are creating a variable and assigning a string value to it appending the value stored in the variable called rows.

line 5, you are updating the value of the element with an ID of "rows". The value you are setting is that stored in the variable called rows.

line 6 -14, you are using the jQuery ajax method to send the value stored in "sendString" to the page called addrow.htm. If the process is succesful, you are accepting some data back from that page (I dont know how it would since its an HTML page, but OK) in the form of a variable called "msg". You are using that msg value and leveraging the jQuery method after(), then executing a method called loadDatePicker(), assuming to show a calendar.

lines 17-25 is for another function called deleteRow and it accepts a parameter.

line 19 is commented out so its not used.

line 20 is a variable that accepts the value of the parameter you accepted
in the function.

line 21, you are creating a variable called deletedRows and using jQuery to get the value of the element with an ID of "deletedRows". I assume thats an input element.

line 22, just assigning a value to this variable.

line 23, changing the style of an element that matches that ID (using variable value)

line 24, using jQuery, updating the value of the element with an ID of "deletedRows".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.