Jump to content

changing div style property onclick


bindiya

Recommended Posts

I have a div which shows and hide when clicking on More and Less button.

I have a pagination code in php written in this div.So when i click  next button the next page come but the div will be close.How can i make this div opened when i go to the next page.


<script type="text/javascript"> 




function toggle_fulltxt(id) {
var v = document.getElementById('fulltxt'+id).style.display;
var morelnk;
var lesslnk;
if (v=='none') {
	v='inline';
	morelnk='none';
	lesslnk='block';
} else {
	v='none';
	morelnk='inline';
	lesslnk='none';
}
document.getElementById('fulltxt'+id).style.display = v;
document.getElementById('fulltxtlnk'+id).style.display = morelnk;
document.getElementById('lesstxtlnk'+id).style.display = lesslnk;
return false;
}

                            </script>
                            <script>
function divs_style(){
document.getElementById('fulltxt001').style.display="inline";
}
</script>

<div id="fulltxtlnk001" style="display:inline">... <a href="" onClick="return toggle_fulltxt('001')" onMouseOver="window.status='Show full description'; return true;" onMouseOut="window.status=''; return true"><span class="style28">LISTS  OF HOTELS</span> ></a></div> 
                                    <div id="fulltxt001" style="display:none"> 
<?php

//Next page:
$next_page = $page + 1;
if($next_page <= $total_pages) {
echo('<a [color=red]onclick="divs_style();"[/color] href='.$pagename.'?limit='.$limit.'&page='.$next_page.'&emir='.$emi.' ><b>Next</b></a> > >');
}

?></p>
</div><div id="lesstxtlnk001" style="display:none"><a href="" onClick="return toggle_fulltxt('001')" onMouseOver="window.status='Hide full description'; return true;" onMouseOut="window.status=''; return true">< Less</a></div>

Link to comment
Share on other sites

If I understand you right, with or without jQuery, you'd need to preserve the DIV state(s) by passing a parameter(s) within the pagination links. As an example:

 

<a href="pagination.php?page=2&show_more=1">Next</a>

 

Then at the end of your <body>:

 

<?php if (!empty($_GET['show_more']) && $_GET['show_more']) { ?>
    <script type="text/javascript">
        document.getElementById('my_div').style.display = 'block';
    </script>
<?php } ?>

 

That's just to demonstrate the logic a little, fitting it into your own code will require some work. I wouldn't use this method myself though as it relies upon JavaScript to show the contents - though I'm not certain I followed your explanation well.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.