|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
kaas Smarty Rookie
Joined: 05 Feb 2009 Posts: 13
|
Posted: Mon Jun 15, 2009 1:18 pm Post subject: fenêtre pop up et refresh de page |
|
|
Bonjour,
je dispose d'une page qui contient un formualire d'ajout d'utilisateurs.
J'ai besoin de gérer dans la même page les droits de l'utilisateur.
Code: |
<h1>{#ADD_USER#|upper}</h1>
<form name="formuser" id="formuser" method="post" action="add_user.php" class="forms">
<div id="zone_data">
<table align="left">
{section name=droits show = $afficher_droits}
<tr>
<td width="45%" valign="top"><td>
<td width="45%" valign="top">{include file="frame_droits.tpl"}<td>
<td width="45%" valign="top">ghfgdhf2<td>
</tr>
{/section}
<tr>
<td>
<label for="login">Identifiant :</label><br/>
<input name="login" type="text" id="login" size="15" />
<td>
</tr>
<tr>
<td>
<label for="nom">Nom :</label><br/>
<input name="nom" id="nom" type="text" size="20"/>
</td>
<td>
<label for="prenom">Prénom :</label></br>
<input name="prenom" id="prenom" type="text" size="30"/>
</td>
</tr>
<tr>
<td>
<label for="service" >Service :</label><br/>
<input type="text" id="service" name="service" size="30">
</td>
<td>
<label for="fonction">Fonction :</label><br/>
<input name="fonction" id="fonction" type="text" size="30" />
</td>
</tr>
<tr>
<td>
<label for="phone">Numéro de téléphone :</label><br/>
<input name="phone" id="phone" type="text" size="20" />
</td>
<td>
<label for="mail">Courriel :</label><br/>
<input name="mail" id="mail" type="text" size="30" />
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<input name="droits" type="button" value="Attribuer droits" class="button" onclick="window.open('droits_utilisateur.php','','toolbar=no,status=no,width=450,height=250,left=500,top=300,scrollbars=yes,top=no,location=no,resize=yes,menubar=no')" />
<p class="buttons">
<input name="Submit" type="submit" value="Valider" class="button" />
<input name="cancel" type="button" value="Annuler" class="button" onclick="javascript:window.location.href='utilisateur.php';" />
</p>
</td>
</tr>
</table>
</diV
</form>
|
Pour cela j'ouvre une fenêtre pop up qui me permet de faire le choix d'une ressource (table) et d'octroyer des droits sur cette ressource.
Code: |
<form name="droits" id="droits" method="GET" action="add_droits.php" class="forms">
<div id="popup_data">
<table>
<tr>
<td><label for="ressource"><span id="monlabel">Table :</span></label></td>
<td colspan="3" >
<select id="ressource" name="ressource" />
<option></option>
{foreach from=$smarty_xml_file item=table}<option>{$table->nom}</option>{/foreach}
</select>
</td>
</tr>
<tr>
<td><label for="consulter"><span id="monlabel">Consulter :</span></label></td>
<td colspan="3"><input type="checkbox" name="consulter" id="consulter" size="20"></td>
</tr>
<tr>
<td><label for="ajout"><span id="monlabel">Insertion :</span></label></td>
<td colspan="3"><input type="checkbox" name="ajout" id="ajout" size="20" ></td>
</tr>
<tr>
<td><label for="maj"><span id="monlabel">Mise à jour :</span></label></td>
<td colspan="3"><input type="checkbox" name="maj" id="maj" size="20" ></td>
</tr>
<tr>
<td><label for="suppress"><span id="monlabel">Suppression :</span></label></td>
<td colspan="3"><input type="checkbox" name="suppress" id="suppress" size="20" ></td>
</tr>
</table>
<input name="valider" type="submit" value="Valider" onclick="window.opener.location.reload()" class="button" />
<input name="annuler" type="button" value="Annuler" class="button" onclick="window.close()" />
</div>
</form>
|
L'opbjectif : je veux en fermant la fenêtre pop up, repartir à la fenêtre appelante, en mettant à jour les droits de l'utilisateur et en ayant toujours les informations auparavant saisies sur l'utilisateur malheureusement pour moi c'est toute la page qui est raffraichie.
comment faire pour eviter le raffraichissement de toute la page ? j'ai pensé aux frames mais on me dit que c'est depassé.
Je vous remercie d'avance de me consacrer un peu de votre temps. |
|
Back to top |
|
ceadreak Smarty n00b
Joined: 08 Feb 2010 Posts: 4
|
Posted: Tue Feb 09, 2010 10:47 am Post subject: |
|
|
Bonjour,
En ce qui me concerne, j'ai une application qui utilise un système similaire.
Pour le rafraichissement, je colle cette action à la balise body de mon popup :
Code: | onunload='window.opener.fonction();' |
Et dans la fenêtre qui appelle le popup :
Code: |
<script type="text/javascript">
function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}
function fonction() {
window.location.replace("http://" + window.location.hostname + "/timer/index.php?page=taskList&projectid="+ gup("projectid"));
}
</script>
|
Remplacer ce qu'il faut dans la fonction "fonction()"
Le paramètre "name" de la fonction "gup()" sert à récupérer le paramètre (ici projectid) du popup.
Si tu veux que ca soit instantané, sans rafraichissement, tu peux appeler une petite fonction ajax qui va te rafraichir uniquement un div, ou un span, ou une textbox, ...
Tu devrais trouver ton bonheur avec ce bout de code :
Code: |
function ajax(url,mydiv){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject(“Msxml2.XMLHTTP”);
} catch (e) {
try{
ajaxRequest = new ActiveXObject(“Microsoft.XMLHTTP”);
} catch (e){
alert(“Your browser broke!”);
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById(mydiv);
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
ajaxRequest.open(“GET”, url, true);
ajaxRequest.send(null);
}
|
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|