0

Hello,
using for each of jquery am fetching td's name
but if try to test it by removing name from firbug and try to submit it then my code is breking.
so first question, what should anyone do in such case?
and another regarding my code is:

        $('#SkillDetails_table tr').each(function()
        {
            var temp_tr_id = $(this).attr('id');    
            if(temp_tr_id)
            {
                if(temp_tr_id.indexOf('skillDetails') !== -1)
                {                   
                    var Splitted_String = temp_tr_id.split('-');
                    var validation_index=Splitted_String[1];
                    if(validation_index)
                    {
                        var Splitted_String = temp_tr_id.split('-');
                        var TR_ID=Splitted_String[1];                            
                            // fetch values from page
                            // HERE WHAT IF I DO NOT GET $("input[name='skillDetails[" + TR_ID + "]['skillType']']" )
                            // i.e. user has deleted it from firebug 

                            var SKILL_TYPE_NAME=$("input[name='skillDetails[" + TR_ID + "]['skillType']']" ).val().trim();
                            var SKILL_NAME=$("input[name='skillDetails[" + TR_ID + "]['skill']']" ).val().trim();

                            var PROF_LEVEL_VALUE=$('#prof_level-'+TR_ID).val().trim();
                            var EXP_YEARS_VALUE=$('#exp_year-'+TR_ID).val().trim();
                            var EXP_MONTHS_VALUE=$('#exp_months-'+TR_ID).val().trim();
                            var LAST_USED_VALUE=$('#last_used_year-'+TR_ID).val().trim();
                            var DESCIPTION_VALUE=$('#description-'+TR_ID).val().trim();

                // here i want soming like if loop that,if i did not get required values then do not go to ajax call.

                            // save values to database using ajax call
                                    $.ajax({
                                            });
                    }
                    else{alert("no tr id got here");}
                }
                else{//return false;
                }
            }
            else
            {}
        });
        if(save_value==true)
            alert("Your data has been saved in draft status.");
        else
            alert("NOT SAVED DATA INTO DRFAT");
    }

I know code is very worst,
but suggestions are welcome.

2
Contributors
1
Reply
11
Views
3 Years
Discussion Span
Last Post by kaleemullah360
0
  1. we can't delete javascript using firbug. second if we can then here you go...
    when var SKILL_TYPE_NAME=$("input[name='skillDetails[" + TR_ID + "]['skillType']']" ).val().trim(); will be deleted the var SKILL_TYPE_NAME is undefined so check it type.

    if(typeof(var) === 'undefined'){//do stuff in case of variable line deleted using firebug.
    }else {//do normal stuff here. }

  2. To find a required value use this

    for (var k in target){if (target.hasOwnProperty(k)) {
    alert("Key is " + k + ", value is" + target[k]);}
    }

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.