3
Well, I need to make sure that when clicking a link from one page go to another and only show the content of the id indicated on the first page, can you do this? I’ve searched a lot of places and I can’t find exactly what I’m looking for.
index php.
<a href="interna.php" onclick="toggle_visibility('bloco1');"></a>
<a href="interna.php" onclick="toggle_visibility('bloco2');"></a>
internal.php
<div id="bloco1" style="display:none">
<div id="bloco2" style="display:none">
This is the javascript I used
<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
//-->
</script>
UPDATE Now the blocks are displayed but when I go to the second block all the functionalities of the links (for example back button) do not work, only the first block works perfectly. I noticed that in all links the code inserts internal.php? show=bloco1 for example, I don’t know if this is what’s troubling you now.
<a href="interna.php?exibir=bloco1"></a>
<a href="interna.php?exibir=bloco2"></a>
<script>
function queryObj() {
var result = {}, keyValuePairs = location.search.slice(1).split("&");
keyValuePairs.forEach(function(keyValuePair) {
keyValuePair = keyValuePair.split('=');
result[decodeURIComponent(keyValuePair[0])] = decodeURIComponent(keyValuePair[1]) || '';
});
return result;
}
loads the content after everything is rendered
$(document).ready(function () {
calls the method to parse the url
var objetoParaOcultar = queryObj();
shows div with id sent by parameter
$('#' + objetoParaOcultar.exibir).show();
})
</script>
Send mode GET, buddy
– Silvio Andorinha
Silvio Andorinha I didn’t understand what you meant, I’m not very good at javascript, I could explain?
– user4451