View Full Version : Switch Content Script - dynamic use

07-02-2005, 11:20 PM

I am new to the web design and to the use and adaptation of different scripts.
I really liked the switch content script but I don't know what exactly to modify on my table so to make the script working.
You can see my page on www.film-francais.com (http://www.film-francais.com).

What I would like to do is when you click on the Title ("Titre"), a new row opens just below and there you could read the sysnopsis of the film (another field retrieved from the db).
The fields of my db are: Id,Titre, Realisateur,Annee, Sysnopsis; ets.
Something like http://www.comscripts.com/scripts/php.phpmyshop.1114.html (http://http://www.comscripts.com/scripts/php.phpmyshop.1114.html) in the middle of the page - "Les commentaires" (the comments), and when you click on one of them, you got the requested information.

Many many thanks in advance,

07-03-2005, 06:16 AM
Here is their script:
<script type="text/javascript">
function OpenLayer(id){
if(document.getElementById(id).style.display == "block") {
document.getElementById(id).style.display = "none" ;

} else {
document.getElementById(id).style.display = "block" ;

window.status = document.getElementById(id).style.display;
</script>and here is an example of their markup that uses it:
<table border="0" width="100%" cellspacing="1" cellpadding="1">

<tr bgcolor="#FFFFFF">

<td><a href="javascript:OpenLayer('commentaire1');"
onmouseout="window.status='';return true;" onmouseover="window.status='Les Commentaires';return true;">
<b>Bon de commande en PDF ?</b></a></td>

<td align="left">
par <a href="/scripts/?auteur=9275">Fred VICTOR</a>
<td nowrap="nowrap" align="center">
<img src="/images/star/star_9.gif" width="55" height="12" alt="9/10" /></td>
<td colspan="3" bgcolor="#F2F5F7">
<div id="commentaire1" style="display:none">
&nbsp;Le : <u>20-04-2005</u>
bonjour &agrave; tous <br />
pour ma part tr&eacute;s satisfait de ce script, je me demandais si gr&acirc;ce &agrave; FPDF il y aurait possibilit&eacute; de g&eacute;n&eacute;rer le bon de commande en PDF. Ceci permettrait tr&eacute;s simplement de l'imprimer OU de l'adresser par mail pour compl&eacute;ter un paiement en ligne (Paypal par exemple). Je pense que c'est possible mais je ne suis pas personnellement assez bal&eacute;ze pour l'aboutir. Si d'aucuns veulent si int&eacute;resser ... </blockquote>
</tr>I'm not wild about the some of the methods used but, it is simple and shows one important feature of any set-up of this kind. The content to be expanded is in a division (<div>) inside a table cell (<td>) not a table element (<table>, <tbody>, <tr> or <td>) itself.


Blue: essential script calls & style
Red: id used for this particular case, each case needs a unique id
Green: added features, that either enhance (mouse events) or allow for proper display/format (colspan=3 - spans the width of this three column table).

You normally should ask permission to use this but, if I could read French, I think I might see that the page is a demo or leads to a demo. I take it that you read the language so, you decide.

07-05-2005, 11:44 AM
Thanks John,

I will try again.
The difficulty for me come to the right synxat to use when the data source is a db.

Once again - thanks,

07-18-2005, 10:27 AM
well its now working, I was trying the script locally by just dropping my page into a web browser but now its being served it works.