Petite question sur formulaire .. - HTML/CSS - Programmation
Marsh Posté le 23-03-2004 à 16:20:30
tu dois faire un document.form_name.submit(); a la validation et puis recuperer les infos au reload..
Marsh Posté le 23-03-2004 à 16:33:15
ok , c'est bon ca, mais j'aimerais bien ne pas avoir a faire un submit , car c'est pas reelement un submit ...
Marsh Posté le 23-03-2004 à 16:35:50
oui mais t as pa le choix..de tte façon tu recharges ta page non?
Marsh Posté le 23-03-2004 à 16:39:05
Oui je recharge ma page , dans le fond , t'as bien raison , j'ai pas trop le choix  .
. 
Je fais comment pour faire un submit a partir d'un lien ?
Marsh Posté le 23-03-2004 à 16:43:47
Mais si quelqun aurait une autre methode pour pas perdre mes donnee deja entrer , ca serait mieu que de faire un submit , parce que un submit envoit deja mes donnee a ma base de donnee... donc j'aimerais mieu une uatre facon. 
 
Quelqun a une idée ?
Marsh Posté le 23-03-2004 à 16:53:33
le code php : 
<? 
$cpt = isset($_POST['cpt']) ? $_POST['cpt'] : 3; 
?> 
 
t as ta balise form :  
 <form name='form1' action ='this_page.php' method='post'> 
 
alors dans ton formulaire tu met un champ du genre  
 <input type='hidden' name='cpt' value='<?echo $cpt;?>'>  
 
et un lien pr ajouter 
<a href='javascript:void(0)' OnClick='document.form1.cpt.value = eval(document.form1.cpt.value + 1); document.form1.action="this_page.php?action=add"; document.form1.submit();'>Ajouter</a>
Marsh Posté le 23-03-2004 à 17:07:37
voila c bourrin mais t as tt ce qu il te faut: 
 
<!-- #include file="./common/conn.asp" --> 
<% 
 'If Session("id" ) = "" AND Session("nom" ) = "" Then Response.Redirect "main.asp" 
 'If NOT session("admin" ) and NOT session("president" ) Then response.redirect "main.asp" 
 logged = 0 
 If Session("id" ) <> "" AND Session("mail" ) <> "" Then logged = 1 
 SortBy = "sondages.ID_sondage" 
 If Request.QueryString("tri" ) <> "" Then SortBy = Request.QueryString("tri" ) 
 StrSQL = "SELECT sondages.Question, sondages.ID_Sondage, DateUp, Online,  nbreponse FROM Sondages, Repondre, Reponses WHERE sondages.ID_sondage = repondre.ID_sondage AND repondre.ID_reponse = reponses.ID_reponse ORDER BY "& SortBy 
 Set rsSondage = Server.CreateObject("ADODB.RecordSet" ) 
 rsSondage.CursorLocation = 3 
 rsSondage.open StrSQL, conn, 3, 3 
 '--------------- Gestion de la page ------------------------ 
 If Request.QueryString("iPage" ) <> "" Then 
 	Page = Request.QueryString("iPage" ) 
 Else 
 	Page = 1 
 End If 
  
 If Request.QueryString("NumPageMini" ) = "" then 
 	NumPageMini = Int(1) 
 Else 
 	NumPageMini = CInt(Request.QueryString("NumPageMini" )) 
 End If 
 '----------------------------------------------------------- 
  
  
 If Not rsSondage.EOF Then 
 	rsSondage.PageSize = 4 
 	rsSondage.AbsolutePage = Page 
 	NbPagesTotal = rsSondage.PageCount 
 End If 
i = Request.Form("i" ) 
If i = "" Then i= 3 
%> 
<html> 
<head> 
<title>Add Sondage</title> 
<link rel="stylesheet" href="common/wmun.css" type="text/css"> 
<script language='javascript'> 
<!-- 
<% 
If Request.QueryString ("msg" ) = "added" Then Response.Write "alert('successfully added');" 
If Request.QueryString ("msg" ) = "modified" Then Response.Write "alert('successfully modified');" 
%> 
 
function test_sond() 
{ 
 var str_err = "Informations incorrectes : \n"; 
 if(document.sond.question.value == "" ) 
 	str_err += "  - Question\n"; 
 <% 
 	j = 1 
 	While j < CInt(i) 
 %> 
 if (document.sond.reponse<%= j%>.value == "" ) 
 	str_err += "  - Champ Reponse numéro <%= j%>\n"; 
 <% 
   j = j + 1 
 	Wend 
 %> 
 if (str_err != "Informations incorrectes : \n" ) 
 	alert(str_err); 
 else 
 { 
 	document.sond.action = "add_sondage_finish.asp"; 
 	document.sond.submit(); 
 } 
} 
//--> 
</script> 
</head> 
<body text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> 
<table width="745" height="100%" cellpadding="0" cellspacing="0" border="0"> 
 <tr> 
 	<td height="115"> 
   <table width="745" height="120" cellpadding="0" cellspacing="0" border="0"> 
     <tr> 
     	<td height="120"><img src="./logo/BAN_MUM3.jpg" border="0"></td> 
     </tr> 
   </table> 
 	</td> 
 </tr> 
 <tr> 
 	<td width="745"> 
   <table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0"> 
   	<tr> 
     <td width="140" bgcolor="#F5F5F5"> 
     	<br><br> 
     	<table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#F5F5F5" name="menuleft"> 
       <tr> 
       	<td height="100%" width="100%" valign="top" align="left"> 
         <br> 
       	<!-- #include file="./menu_logged.asp" --> 
       	</td> 
       </tr> 
     	</table>       
     </td> 
     <td width="613" valign="top" align="center"> 
     	<br><br><br> 
     	<table width="98%" cellpadding="5" cellspacing="0" border="0" align="center"> 
       <tr> 
       	<td> 
         <table width="100%" cellpadding="0" cellspacing="0"> 
         	<tr> 
           <td class="maintitle" valign="bottom">SONDAGES</td> 
         	</tr> 
         	<tr> 
           <td class="maintitle" valign="top"><hr size="2" color="#575757" width="100%"></td> 
         	</tr> 
         </table> 
       	</td> 
       </tr>       
       <tr> 
       	<td class="maincontent">Nouveau Sondage</td> 
       </tr> 
     	</table> 
     	<form name="sond" action="add_sondage_finish.asp" method="post"> 
     	<input type="hidden" name="i" value="<%= i%>"> 
     	<table cellpadding="5" cellspacing="0" border="0"> 
       <tr> 
       	<td class="maincontent"><b>Question  </b></td> 
       	<td><input type="text" name="question" value="<%= Request.Form("Question" )%>" size="50"></td> 
       </tr> 
       <tr><td><br><br></td></tr> 
       <tr> 
       	<td class="maincontent" colspan="2"><b>Réponses</b></td> 
       </tr> 
       <tr> 
       	<td colspan="2" align="right"> 
         <table align="right" border="0" cellpadding="0"> 
         	<tr> 
           <td><input type="button" name="add" value="   Ajouter une réponse   " OnClick="document.sond.i.value =Number(document.sond.i.value) + 1;document.sond.action='add_sondage.asp?action=add';document.sond.submit();"></td> 
           <td><input type="button" name="rem" value="Supprimer une réponse" OnClick="if ((Number(document.sond.i.value) - 1) <= 2){ alert('Suppression impossible, deux champs réponse minimum'); return false;}document.sond.i.value =Number(document.sond.i.value) - 1;document.sond.action='add_sondage.asp?action=rem';document.sond.submit();"></td> 
         	</tr> 
         </table> 
       	</td> 
       </tr> 
       <% 
       	j = 1 
       	While j < CInt(i) 
         val = "" 
         If Request.Form ("reponse"&j) <> "" Then val = Request.Form ("reponse"&j) 
       %> 
       <tr> 
       	<td align="right" class="simple"><%= j%></td> 
       	<td><input type="text" name="reponse<%= j%>" value="<%= val%>" size="50"></td> 
       </tr> 
       <% 
         j = j + 1 
       	Wend 
       %> 
       <tr> 
       	<td colspan="2" align="right"><input type="button" name="alright" value="Valider" OnClick="test_sond();"></td> 
       </tr> 
     	</table> 
     	</form> 
     </td> 
   	</tr> 
   </table> 
 	</td> 
 </tr> 
</table> 
   <script language=JavaScript src="./menu_array.js" type=text/javascript></script> 
   <script language=JavaScript src="./mmenu.js" type=text/javascript></script> 
</body> 
</html> 
<!-- #include file="./common/end_conn.asp" --> 
                                                    
Marsh Posté le 23-03-2004 à 15:51:34
Bonjour , je travaille présentement sur un formulaire style agenda et j'ai un petit probleme que j'arrive pas a corriger.
Par défault mon formulaire a trois tâche (Liste déroulante) que l'on peut rentrer pour une journée , j'ai ajouter un bouton qui permet de rajouter toujour trois ligne de plus.
Mon probleme , si je remplit mes trois ligne et que je manque d'espace donc j'appuit sur le bouton pour ajouter des lignes (reload la page avec (6) comme parametre à la page , bien je perd les information deja rentrer. Que puis-je faire ?