Hello
Im new here, I need help if my syntax is correct.
if(first_name != <
row.@firstname>)
{ alert("Record already exists! Search and use the record to continue transaction!")};
I attached the whole function. What I want to do is that whenever a user tries to create a new record using first_name, middle_initial, last_name and date_of_birth on the textboxes, these things will happen,
1. I have Sp working already that gets the fields of the table customer using parameter
2. then on my page below, the value of the text box will be transfered to variable
3. A condition to compare if value on the text boxes are all the same in the existing table, if yes, then alert will be existing record appered.
Can somebody help me? I may missing out syntax. I also included the working SP below the code.
Thank you very much.
----- This is my code in my .asp file--------
function CheckCustomer() {
var cFirstName = $("#CustomerFirstName").val();
var cMidInitial = $("#CustomerMiddleInitial").val();
var cLastName = $("#CustomerLastName").val();
var cBday = $("#CustomerBday").val();
var cClientID = "<%=clientID%>"
//alert(cFirstName + cMidInitial + cLastName + cBday);
//alert("<%=clientID%>");
$.get("bdo_search_customerrecord.asp",
{
first_name: cFirstName,
mid_initial: cMidInitial,
last_name: cLastName,
date_of_birth: cBday,
client_id: "<%=clientID%>"
},
function(data) {
if(data.rows.length > 0) {
var row = data.rows[0];
alert(row);
//article_code = row.article_code;
// if ($(cFirstName).val() = <
row.@firstname> );
// if ($(cLastName).val() = <
row.@lastname> );
// if ($(cMidInitial).val() = <
row.@middleinitial> ) ;
// if ($(cBday).val() = <
row.@@birthdate> ) ; {
// }
//return;
if(first_name != <
row.@firstname>)
{ alert("Record already exists! Search and use the record to continue transaction!")};
}
// put need to do here
},
"json"
);
}
--------------------------------
----- MY SP --------------
ALTER
PROCEDURE
[dbo]
.
[get_bdo_customerrecord] @firstname
varchar
(
50
),
@lastname
varchar
(
50
),
@middleinitial
varchar
(
2
),
@birthdate
datetime
,
@client_id
int AS
/***********************************************************************
Procedure Name: [dbo].[get_bdo_customerrecord]
Description: retrieves searched bdo customer record
***********************************************************************/
SELECT
first_name
,
middle_initial
,
last_name
,
date_of_birth
FROM
customer
WHERE
first_name
=
@firstname
AND
middle_initial
=
@middleinitial
AND
last_name
=
@lastname
AND
date_of_birth
=
@birthdate
AND
client_id
=
'5390'