开发者

Jquery Problem with the add and Update

开发者 https://www.devze.com 2023-01-09 02:18 出处:网络
Iam having a html table which has some number of rows say 17 rows .I have a small form with the fields which adds the form values to this html table . I have a unique field in the table say part numbe

Iam having a html table which has some number of rows say 17 rows .I have a small form with the fields which adds the form values to this html table . I have a unique field in the table say part number

I Have Two buttons named add and Update .When i click on "Add" .it Should add the part number with the appropriate form value(this i have Done).But if the Part number already exists in the html table It Should Say "Part number already exists"

Update: in the Update it should select a row and show the values in the form fields (this part I have Done ) when I click on update It should update that row and if the User changes the part number field to the existing part number in the table then it should Say it part number already exists

Here is the sample code that i have written for add button and would be the same for update

$("#addbtnPO").click(function(){
    if ($("#myform").validationEngine({returnIsValid:true})) {
        var totrows= $('#mytable').attr('rows').length;
        for(var i=2;i <= totrows-1; i++){
        partvalue   = $("#mytable").find('td > #partno_'+i).text();
                if($('#partno').attr('value') == partvalue){
                    $("#error").text('# already exists');
                    return;         
            }
        }                       
        $("#hiddenvariable").attr("value","");
        $("#hiddenvariable").attr("value","a开发者_StackOverflow中文版dd");
        $("#myform").submit();
    }
});

//here My Problem is Iam Starting value for "partno" =>from "2" i should be able to start from Partno1 .Please Help me .

Please Suggest me appropriate soloution.


My Problem is Iam Starting value for "partno" =>from "2" i should be able to start from Partno1

Do not fully understand your question but try changing below line:

for(var i=2;i <= totrows-1; i++){

To:

for(var i=1;i <= totrows-1; i++){
0

精彩评论

暂无评论...
验证码 换一张
取 消