Dear All
From one div i am allowing user to select headers using autosuggestion ( let us call this
All Div Header)
and other div had headers aleady allocated or selected by user
(let us call it
Selected
Header
Div)
In short user selects an header from
All Div Header (as well as database table)
and after clicking
Add
and that header is transferred to
Selected Header Div( as well as database table)
I am allowing user to select header using 'autosuggestion'
Suppose the All Div header has only one value Cat (only one row)
and user types Dog (suggestion will show zero or no records)
In this case when Add is clicked
It should get added in both these div's and database tables
All Div Header
Selected Header Div
Which is happening no issues here
What i want is
In case the header is new (like specified above when user types Dog and clicks add)
I Want to add new header box to appear
If user types Cat ( The name exists) and clicks Add
the the header will get added (in
Selected Header Div
) without asking
I had written following JQUERY;
-
$("#addheader").click(function () { // user had selected header and click Add button to add this header in
-
$('#findheaderiddiv').empty(); // storing number of rows from
All Div Header using JQERY
-
- var url = "findheaderid.php" // JQUERY program to find number of rows in All Div Header using
-
var data = {
-
keyword: $('#keyword').val() // complete string (typed by user )is passed
-
};
-
$('#findheaderiddiv').load(url, data, Headeradd()); //
I want to call function
Headeradd() after i get output of findheaderid.php buy it seems it is called before completion of findheaderid.php Pls help
-
});
-
function Headeradd() {// to be called after
$('#findheaderiddiv').load(url, data) is over
-
var hid=$('#findheaderiddiv').text(); // get value store in line number 8 and store in variable
hid
-
-
if (hid>=1) // I am unable to fetch this value it seems
Headeradd() in line no 8 is not called after completion of
-
{alert("header exists");
-
$('#findheaderiddiv').empty();
- // JQUERY to add this header in Selected Header Div
-
}
-
else
-
{ var url = "updateheader.php"
-
var data = {
-
keyword: $('#keyword').val(),
-
recordid: $('#recordid').val()
-
-
};
-
$('#selectheaderdiv').load(url, data) ;// new header and hence update it in both Tables and Div's this program working OK
-
-
$('#findheaderiddiv').empty();
-
}
-
}