How to remove/hide <div></div> tags only without the content?
- by candies
For example I have:
<div id ="test">[the content here]</div>
The content within the div tags will appear after I called the id of div using ajax.
This is the code:
function dinamic(add)
{
var kode = add.value;
if (!kode) return;
xmlhttp2.open('get', '../template/get_id.php?kode='+kode, true);
xmlhttp2.onreadystatechange = function() {
if ((xmlhttp2.readyState == 4) && (xmlhttp2.status == 200))
{
var add = document.getElementById("test");
add.innerHTML = xmlhttp2.responseText;
}
return false;
}
xmlhttp2.send(null);
}
So it will appear <div id="test">A</div>
I'd like to put the content of div - A into mysql query.
$test = $_GET['test'];
$query = "select * from example where category='$test'";
I've tried to make variable $test of the div id to get the content but result of the query in category is none.
I tried again, I put the div in to the query
$query = "select * from example where category='<div id=\"test\">A</div>'";
Yes, It works. But when I did query on navicat, no results I got because there's spaces between A that is <div> and </div>.
How to remove/hide the div tags only so its only appear the content?
> $query = "select * from example where category='A'"; <
Edit:
If I echo the query on firefox browser will say "$query = "select * from example where category='[space]A[space]'";"
And look at the bug(I use firebug), it will say "$query = "select * from example where category='<div id="test">A</div>'";"
So my guessing why can't get result after query on navicat is there's spaces between A([space]A[space]), just have no idea how to remove/hide the div tags, I want to get this result only "$query = "select * from example where category='A'";"
Thanks.