Prbleme de javacsript
localhost
Messages postés
2
Statut
Membre
-
alexdelareunion Messages postés 555 Statut Membre -
alexdelareunion Messages postés 555 Statut Membre -
Bonjour,
j'ai un probleme de java script j'ai developpe un code pour changer des cadre via WYSIWYG.il marche tres bien sur internet explorer mais sur mozilla il ne veut rien savoir je pense que cele viens du javascript j'ai essayer un tas de truc mais rien y fait non seuulement il ne veut pas me changer le cadre mais en pludsil m'enleve celui que j'avais si quelqu'un a une idée je l'en remerci d'avance j'envoi le code en question
<?php
session_start();
require('config.php');
require ("BDD.php"); // Contient les fonctions de (dé)connection à la base, ainsi que celle pour exécuter les requêtes
require('document_class.php');
require ("StyleParagraphe.class.php");
//*****************************************************************************************************************************//
//*****************************************VERIFICATION DE L'ACCES**********************************************************//
//*****************************************************************************************************************************//
if(!isset($_SESSION['log']) || !isset($_SESSION['last_access']) || !isset($_SESSION['ipaddr']))
{
header('location: index_compte.php?adr=modifierCadre.php');
die();
}
//On vérifie si le temps d'inactivité n'est pas dépassé ($session_timeout est définie dans config.php)
if(time()-$_SESSION['last_access']>$session_timeout)
{
header('location: index_compte.php?adr=modifierCadre.php');
die();
}
//On compare l'adresse IP avec l'adresse d'accès du client
if($_SERVER['REMOTE_ADDR']!=$_SESSION['ipaddr'])
{
header('location: index_compte.php?adr=modifierCadre.php');
die();
}
//On réinitialise la variable de session du dernier accès
$_SESSION['last_access']=time();
if($_SESSION['domaine'] != 'A' && $_SESSION['domaine'] != 'S')
{
header('location: deconnect.php');
}
if(isset($_POST['style']))
{
$id=$_GET['id_cadre'];
$style=$_POST['style'];
getResQuery("UPDATE ICE_CADRE SET STYLE='$style' WHERE ID_CADRE=$id");
echo "<script language='Javascript'>";
echo "<!--\n";
echo "window.opener.location.href='index.php?scroll='+window.opener.document.body.scrollTop;";
echo "window.close();\n";
echo "// -->";
echo "</script>\n";
}
//JE PENSE QUE LE PROBLEME EST APRES LE ELSE IF
?>
<script language="javascript">
function changeStyle(sousStyle)
{
if (document.getElementById)
{
obj = document.getElementById("style");
obj.innerText = sousStyle;
}
else if (document.all)
{
document.all["style"].innerHTML = sousStyle;
}
}
</script>
<html>
<head>
<title>Modifier le style du cadre</title>
<link rel="stylesheet" media="screen" type="text/css" href="CSS/style.css">
<script language="javascript" type="text/javascript" src="jscripts/scripts.js"></script>
</head>
<body class="body2">
<br>
<br>
<br>
Sélectionnez le style du cadre et cliquez sur "valider"
<div id="selection_style_cadre">
<?php
$resultBDD = getResQuery("SELECT STYLE FROM ICE_CADRE WHERE ID_CADRE=".$_GET['id_cadre']);
$cadre = mysql_fetch_array($resultBDD);
$cStyleParagraphe = new StyleParagraphe ();
$cStyleParagraphe->ChargeDonnees ();
echo '<script language="javascript">';
echo 'imageFond(\'images/styles/'.$cStyleParagraphe->repertoireStyle.'/fond.jpg\');';
echo '</script>';
$fontPolice = "";
$fontTaille = 13;
$fontGras = 0;
$couleurTitre = 'ffffff';
$img;
$x;
$y;
$requete=getResQuery("SELECT INTITULE, COULEUR_TITRE, FONT, FONT_TAILLE, FONT_GRAS FROM ICE_STYLE_CADRES WHERE ID_STYLE_CADRE=".$_SESSION['id_style_cadre']);
if ($resultat = mysql_fetch_array($requete))
{
$fontPolice = $resultat['FONT'];
$fontTaille = $resultat['FONT_TAILLE'];
$fontGras = $resultat['FONT_GRAS'];
$couleurTitre = $resultat['COULEUR_TITRE'];
}
$doc = new Document('document.php');
$tab=$doc->listing1folder('images/styles/'.$resultat['INTITULE']);
if($tab!==NULL)
{
foreach($tab as $sousStyle)
{
echo '<div style="position: relative; margin: 20px; float: left; display: inline; width:100px; height:100px; z-index:1">';
if ( $sousStyle == $cadre['STYLE'] )
echo '<input type="radio" name="sousStyle" value="radiobutton" onClick="changeStyle(\''.$sousStyle.'\');" checked>';
else
echo '<input type="radio" name="sousStyle" value="radiobutton" onClick="changeStyle(\''.$sousStyle.'\');">';
echo $sousStyle;
echo '<table width="100px" height="100px" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">';
echo '<tbody>';
echo '<tr>';
$cStyleParagraphe->DonneImage (1, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td width="'.$x.'px" height="'.$y.'px"><img src="'.$img.'" width="'.$x.'px" height="'.$y.'px"></td>';
else
echo '<td width="22px" height=30px"></td>';
if ( empty ($fontPolice)==false )
$font = 'font-family:'.$fontPolice.';font-size:'.$fontTaille.'px';
else
$font = 'font-family:arial,sans-serif;font-size:13px';
if ( $fontGras==1 )
$font .= '; font-weight:bold';
$cStyleParagraphe->DonneImage (2, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td background="'.$img.'" class="titre" style="color:#'.$couleurTitre.'; '.$font.'">Intitulé</td>';
else
echo '<td class="titre" style="color:#'.$couleurTitre.'; '.$font.'">Intitulé</td>';
$cStyleParagraphe->DonneImage (3, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td width="'.$x.'px" height="'.$y.'px"><img src="'.$img.'" width="'.$x.'px" height="'.$y.'px"></td>';
else
echo '<td width=22px" height="30px"></td>';
echo '</tr>';
echo '<tr>';
$cStyleParagraphe->DonneImage (8, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td background="'.$img.'"> </td>';
else
echo '<td></td>';
echo '<td style="background-color:#ffffff">Et est admodum mirum videre plebem innumeram mentibus ardore ...</td>';
$cStyleParagraphe->DonneImage (4, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td background="'.$img.'"> </td>';
else
echo '<td></td>';
echo '</tr>';
echo '<tr>';
$cStyleParagraphe->DonneImage (7, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td width="'.$x.'" height="'.$y.'"><img src="'.$img.'" width="'.$x.'" height="'.$y.'"></td>';
else
echo '<td></td>';
$cStyleParagraphe->DonneImage (6, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td background="'.$img.'"></td>';
else
echo '<td></td>';
$cStyleParagraphe->DonneImage (5, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td><img src="'.$img.'" width="'.$x.'" height="'.$y.'"></td>';
else
echo '<td></td>';
echo '</tr>';
echo '</tbody>';
echo '</table>';
echo '</div>';
}
}
?>
<div style="clear:both;"></div>
</div>
<div id="bt_valid_cad">
<form name="form1" id="form1" method="post" action="choixStyleCadre.php?id_cadre=<?php echo $_GET['id_cadre']; ?>">
<input type="hidden" name="style" value="essai">
<input type="submit" name="Submit" value="valider">
</form>
</div>
</body>
</html>
j'ai un probleme de java script j'ai developpe un code pour changer des cadre via WYSIWYG.il marche tres bien sur internet explorer mais sur mozilla il ne veut rien savoir je pense que cele viens du javascript j'ai essayer un tas de truc mais rien y fait non seuulement il ne veut pas me changer le cadre mais en pludsil m'enleve celui que j'avais si quelqu'un a une idée je l'en remerci d'avance j'envoi le code en question
<?php
session_start();
require('config.php');
require ("BDD.php"); // Contient les fonctions de (dé)connection à la base, ainsi que celle pour exécuter les requêtes
require('document_class.php');
require ("StyleParagraphe.class.php");
//*****************************************************************************************************************************//
//*****************************************VERIFICATION DE L'ACCES**********************************************************//
//*****************************************************************************************************************************//
if(!isset($_SESSION['log']) || !isset($_SESSION['last_access']) || !isset($_SESSION['ipaddr']))
{
header('location: index_compte.php?adr=modifierCadre.php');
die();
}
//On vérifie si le temps d'inactivité n'est pas dépassé ($session_timeout est définie dans config.php)
if(time()-$_SESSION['last_access']>$session_timeout)
{
header('location: index_compte.php?adr=modifierCadre.php');
die();
}
//On compare l'adresse IP avec l'adresse d'accès du client
if($_SERVER['REMOTE_ADDR']!=$_SESSION['ipaddr'])
{
header('location: index_compte.php?adr=modifierCadre.php');
die();
}
//On réinitialise la variable de session du dernier accès
$_SESSION['last_access']=time();
if($_SESSION['domaine'] != 'A' && $_SESSION['domaine'] != 'S')
{
header('location: deconnect.php');
}
if(isset($_POST['style']))
{
$id=$_GET['id_cadre'];
$style=$_POST['style'];
getResQuery("UPDATE ICE_CADRE SET STYLE='$style' WHERE ID_CADRE=$id");
echo "<script language='Javascript'>";
echo "<!--\n";
echo "window.opener.location.href='index.php?scroll='+window.opener.document.body.scrollTop;";
echo "window.close();\n";
echo "// -->";
echo "</script>\n";
}
//JE PENSE QUE LE PROBLEME EST APRES LE ELSE IF
?>
<script language="javascript">
function changeStyle(sousStyle)
{
if (document.getElementById)
{
obj = document.getElementById("style");
obj.innerText = sousStyle;
}
else if (document.all)
{
document.all["style"].innerHTML = sousStyle;
}
}
</script>
<html>
<head>
<title>Modifier le style du cadre</title>
<link rel="stylesheet" media="screen" type="text/css" href="CSS/style.css">
<script language="javascript" type="text/javascript" src="jscripts/scripts.js"></script>
</head>
<body class="body2">
<br>
<br>
<br>
Sélectionnez le style du cadre et cliquez sur "valider"
<div id="selection_style_cadre">
<?php
$resultBDD = getResQuery("SELECT STYLE FROM ICE_CADRE WHERE ID_CADRE=".$_GET['id_cadre']);
$cadre = mysql_fetch_array($resultBDD);
$cStyleParagraphe = new StyleParagraphe ();
$cStyleParagraphe->ChargeDonnees ();
echo '<script language="javascript">';
echo 'imageFond(\'images/styles/'.$cStyleParagraphe->repertoireStyle.'/fond.jpg\');';
echo '</script>';
$fontPolice = "";
$fontTaille = 13;
$fontGras = 0;
$couleurTitre = 'ffffff';
$img;
$x;
$y;
$requete=getResQuery("SELECT INTITULE, COULEUR_TITRE, FONT, FONT_TAILLE, FONT_GRAS FROM ICE_STYLE_CADRES WHERE ID_STYLE_CADRE=".$_SESSION['id_style_cadre']);
if ($resultat = mysql_fetch_array($requete))
{
$fontPolice = $resultat['FONT'];
$fontTaille = $resultat['FONT_TAILLE'];
$fontGras = $resultat['FONT_GRAS'];
$couleurTitre = $resultat['COULEUR_TITRE'];
}
$doc = new Document('document.php');
$tab=$doc->listing1folder('images/styles/'.$resultat['INTITULE']);
if($tab!==NULL)
{
foreach($tab as $sousStyle)
{
echo '<div style="position: relative; margin: 20px; float: left; display: inline; width:100px; height:100px; z-index:1">';
if ( $sousStyle == $cadre['STYLE'] )
echo '<input type="radio" name="sousStyle" value="radiobutton" onClick="changeStyle(\''.$sousStyle.'\');" checked>';
else
echo '<input type="radio" name="sousStyle" value="radiobutton" onClick="changeStyle(\''.$sousStyle.'\');">';
echo $sousStyle;
echo '<table width="100px" height="100px" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">';
echo '<tbody>';
echo '<tr>';
$cStyleParagraphe->DonneImage (1, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td width="'.$x.'px" height="'.$y.'px"><img src="'.$img.'" width="'.$x.'px" height="'.$y.'px"></td>';
else
echo '<td width="22px" height=30px"></td>';
if ( empty ($fontPolice)==false )
$font = 'font-family:'.$fontPolice.';font-size:'.$fontTaille.'px';
else
$font = 'font-family:arial,sans-serif;font-size:13px';
if ( $fontGras==1 )
$font .= '; font-weight:bold';
$cStyleParagraphe->DonneImage (2, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td background="'.$img.'" class="titre" style="color:#'.$couleurTitre.'; '.$font.'">Intitulé</td>';
else
echo '<td class="titre" style="color:#'.$couleurTitre.'; '.$font.'">Intitulé</td>';
$cStyleParagraphe->DonneImage (3, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td width="'.$x.'px" height="'.$y.'px"><img src="'.$img.'" width="'.$x.'px" height="'.$y.'px"></td>';
else
echo '<td width=22px" height="30px"></td>';
echo '</tr>';
echo '<tr>';
$cStyleParagraphe->DonneImage (8, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td background="'.$img.'"> </td>';
else
echo '<td></td>';
echo '<td style="background-color:#ffffff">Et est admodum mirum videre plebem innumeram mentibus ardore ...</td>';
$cStyleParagraphe->DonneImage (4, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td background="'.$img.'"> </td>';
else
echo '<td></td>';
echo '</tr>';
echo '<tr>';
$cStyleParagraphe->DonneImage (7, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td width="'.$x.'" height="'.$y.'"><img src="'.$img.'" width="'.$x.'" height="'.$y.'"></td>';
else
echo '<td></td>';
$cStyleParagraphe->DonneImage (6, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td background="'.$img.'"></td>';
else
echo '<td></td>';
$cStyleParagraphe->DonneImage (5, $sousStyle, $img, $x, $y);
if ( empty ($img)==false )
echo '<td><img src="'.$img.'" width="'.$x.'" height="'.$y.'"></td>';
else
echo '<td></td>';
echo '</tr>';
echo '</tbody>';
echo '</table>';
echo '</div>';
}
}
?>
<div style="clear:both;"></div>
</div>
<div id="bt_valid_cad">
<form name="form1" id="form1" method="post" action="choixStyleCadre.php?id_cadre=<?php echo $_GET['id_cadre']; ?>">
<input type="hidden" name="style" value="essai">
<input type="submit" name="Submit" value="valider">
</form>
</div>
</body>
</html>
4 réponses
Salut,
c'est tout simplement codé comme un porc !
lol
Excuse moi de l'expression mais c'est vrai.
Ton code ne donne pas envie d'être lu et encore moins d'être compris.
Pour ce qui est de ton JS, c'est bizarre comment tu fais ça...
Je me dis pas pro mais j'ai jamais utilisé de conditions de ce style.
Puis en parlant de conditions ... tu fais que ça et c'est moche ! lol
Penses aux switch case pour gérer les exception ;)
A retravailler dans sa globalité
PS: Je dis pas ça pour t'embéter...
A+
Gaerebut
c'est tout simplement codé comme un porc !
lol
Excuse moi de l'expression mais c'est vrai.
Ton code ne donne pas envie d'être lu et encore moins d'être compris.
Pour ce qui est de ton JS, c'est bizarre comment tu fais ça...
Je me dis pas pro mais j'ai jamais utilisé de conditions de ce style.
Puis en parlant de conditions ... tu fais que ça et c'est moche ! lol
Penses aux switch case pour gérer les exception ;)
A retravailler dans sa globalité
PS: Je dis pas ça pour t'embéter...
A+
Gaerebut
Je suis d'accord, pitié si tu veux de l'aide sur du javascript ne nous balance pas un vieux php.
Déja j'ai vu un truc louche, tu balance des trucs dans le html avant même les balises <html> et <head>, donc si ça marche sous ie ben c'est limite pas normal.
Ensuite qu'est-ce que tu appelle "le cadre" ? perso j'ai pas compris
Déja j'ai vu un truc louche, tu balance des trucs dans le html avant même les balises <html> et <head>, donc si ça marche sous ie ben c'est limite pas normal.
Ensuite qu'est-ce que tu appelle "le cadre" ? perso j'ai pas compris