I am using below textbox to add tags.
When I enter any tag(say 'Java' here) and then press enter, tagit() of jquery is called.
$(function () {
var availableTagname = [<?=$testTagname?>];
$('#demo4').tagit({tagSource:availableTagname, sortable:true, tagsChanged:function (a) {
Counttagname(a);
} });
'a' is a value of the textbox. a = java here. then Counttagname() is called.
function Counttagname(value)
{
if(value!="")
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{ document.getElementById("divcounttagname").innerHTML="";
document.getElementById("divcounttagname").innerHTML=xmlhttp.responseText;
}
}
// alert(value);
xmlhttp.open("GET","<?=base_url()?>index.php/admins/joborders/bindcounttagname/"+value,true);
xmlhttp.send();
}
else
{
document.getElementById("divcounttagname").innerHTML='';
document.getElementById("divcounttagname").innerHTML='<div>There are no Candidate</div>';
}
}
that value (i.e. 'java') is passed in "xmlhttp.open("GET","index.php/admins/joborders/bindcounttagname/"+value,true);"
Now, bindcounttagname() is called in controllder.
function bindcounttagname($value)
{
$this->load->model('mjoborders');
$data['counttagname'] = $counttagname = $this->mjoborders- >Getcounttagname($value);
and then Getcounttagname() is called in model.
function Getcounttagname($value)
{
$data = array();
$Q = $this->db->select('*,count(candidateid) as countcandidate FROM tbl_candidatetag where tagname = "'.$value.'"');
$Q = $this->db->get();
if ($Q->num_rows() > 0)
{
foreach ($Q->result_array() as $row)
{
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
Tag passes as a parameter in above query.
But, When I enter second tag that tag should also pass in query with earlier tag i.e. IN ('java','css3');
But it does not take more than one value as a parameter.
I tried to use array to pass more tags in query like below link but the query does not fetch any row.. 1. "Passing an array to a query using a WHERE clause" 2. passed static two values also in query but it does not fetch any row.
Please tell me how to pass more than one tag as a parameter in query.