i've have a problem when the content of the divs are showed. I want to show divs using a idpost variable, but i dont know how to do this. Now when i push show / hide button only works the first one div. I would like to do this using a id var. The next code is the php file that i use in the index page with a include. It show me all the records of the database with an array.
<?php
include "connections/con1.php";
mysql_select_db($database_con1, $con1);
$query_Recordset1 = "SELECT * FROM `general` ORDER BY `timestamp` DESC LIMIT 9 ";
$result = mySQL_query ( $query_Recordset1 ) ; while ( $row_Recordset1 = mySQL_fetch_array ( $result ) ){
$idpost=$row_Recordset1['idpost'];
$msg_id=$row_Recordset1['timestamp'];
$titulo=$row_Recordset1['titulopost'];
$message=$row_Recordset1['contentpost'];
if (strlen($message) > 100) {
$text = substr($message, 0,600);
echo $idpost;
echo '<div class="article" target="<?php $idpost; ?>">
<div id="noticia">
<h1>
'.$titulo.''." ".''.$msg_id.'
</h1>'.'
<h2 id="noticia_corta">
'.$text.''."...".'
<input type="button" name="answer" value="Show Div" onclick="showDiv()" />
<input type="button" id="hideDivButton" value="Hide Div" onclick="hideDiv()" />
<h2 id="hiddenDiv" style="display:none;">
<div class="answer_list">
'.$message.'
<input type="button" name="answer" value="Show Div" onclick="showDiv()" />
<input type="button" id="hideDivButton" value="Hide Div" onclick="hideDiv()" />
</div>
</h2>
</div>
</div>';
}
} ?>
And this is the js function that do the action of the divs, but i dont know how to focus the problem
<script type="text/javascript" src="http://ift.tt/NZIHqJ
libs/jquery/1.3.0/jquery.min.js"></script>
<script type='text/javascript'>
function showDiv() {
document.getElementById('hiddenDiv').style.display = "block";
document.getElementById('noticia_corta').style.display = "none";
}
function hideDiv() {
document.getElementById('hiddenDiv').style.display = "none";
document.getElementById('noticia_corta').style.display = "block";
}
Thanks ^^
Aucun commentaire:
Enregistrer un commentaire