Thursday, 28 December 2017

Check duplicate data using Javascript

Use the below Javascript to identify duplicate data - In this sample code, when user enters order number in the tabular form, an error will be thrown if the order number already exists.

<!--duplicate checking for order no -->
<script>
function check_order_no(pThis)
{
var j_item_id=pThis.id;
var k_item_id='#f02'+j_item_id.substr(3);
//alert(j_item_id);
//alert(k_item_id);
var h='#'+j_item_id;
//alert(h);
var a= $(h).val();
var g=$(k_item_id).val();
//alert(a);
//alert(g);

if (g)
{
var get = new htmldb_Get(null, $v('pFlowId'),'APPLICATION_PROCESS=Duplicate_Order_no_check',$v('pFlowStepId'));
get.add('AI_ORDER_NO',a);
//get.add('AI_SHIPPING_ID',g);
ret = get.get();
//alert(ret);
if (ret != 0)
{
var get = new htmldb_Get(null, $v('pFlowId'),'APPLICATION_PROCESS=Duplicate_Order_no_shipping_id',$v('pFlowStepId'));
get.add('AI_ORDER_NO',a);
ret = get.get();
if(ret != g)
{
alert('The Order No is already present.Kindly select another Order No');
$(h).val(null);
$(h).focus();
}
}
}
else
{
var i = 1;
var j=0;
var b,a,c,f;
while (i != 0) {
b = "000" + i;
b = pad(i, 4);
d = $('#f03_'+b).val();
//alert(typeof d);
if (typeof d === "undefined") {
i=0;
}
else
{
if(a == d)
{j= j+1;
}
if(j>1)
{
alert('The Order No is already present.Kindly select another Order No');
$(h).val(null);
$(h).focus();
break;
}
i= i+1;
}
}
}
}
</script>

2 comments:

  1. Such a nice blog, I really like what you write in this blog, I also have some relevant Information about Best HR Training In Hyderabad | Hr training institute in Hyderabad! if you want more information.
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training
    Oracle Fusion Financials Online Training
    Big Data and Hadoop Training In Hyderabad

    ReplyDelete