xkamui Their Destiny Was Foreordained | ok, bon bah, je vais vous poster mon code complet parce que là, je comprend trop pas....
Fichier javascript :
Code :
- /*
- Required field(s) validation- By NavSurf
- Visit NavSurf.com at http://navsurf.com
- Visit http://www.dynamicdrive.com for this script
- */
- function formCheck(formobj){
- //1) Enter name of mandatory fields
- var fieldRequired = Array("Rubrique", "Nom", "Adresse", "CP", "Ville", "Tel" );
- //2) Enter field description to appear in the dialog box
- var fieldDescription = Array("Rubrique", "Nom", "Adresse", "Code Postal", "Ville", "Téléphone" );
- //3) Enter dialog message
- var alertMsg = "Vous devez remplir les champs suivants :\n";
- var l_Msg = alertMsg.length;
- for (var i = 0; i < fieldRequired.length; i++){
- var obj = formobj.elements[fieldRequired[i]];
- if (obj){
- switch(obj.type){
- case "select-one":
- if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == "" ){
- alertMsg += " - " + fieldDescription[i] + "\n";
- }
- break;
- case "select-multiple":
- if (obj.selectedIndex == -1){
- alertMsg += " - " + fieldDescription[i] + "\n";
- }
- break;
- case "text":
- case "textarea":
- if (obj.value == "" || obj.value == null){
- alertMsg += " - " + fieldDescription[i] + "\n";
- }
- break;
- default:
- if (obj.value == "" || obj.value == null){
- alertMsg += " - " + fieldDescription[i] + "\n";
- }
- }
- }
- }
- if (alertMsg.length == l_Msg){
- return true;
- }else{
- alert(alertMsg);
- return false;
- }
- }
|
fichier html :
Code :
- <html>
- <head>
- <title>Untitled Document</title>
- <SCRIPT language=JavaScript src="../script/scripts.js" type=text/javascript></SCRIPT>
- <?
- MYSQL_CONNECT ("127.0.0.1","root","" ) OR DIE ("Connection time out" );
- MYSQL_SELECT_DB ("ekklo" ) OR DIE ("Unknown Database" );
- ?>
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- <form name="formcheck" onsubmit="return formCheck(this);" action="add.partner02.php" method="post">
- <p>rubrique : <select name="Rubrique">
- <OPTION></OPTION>
- <?
-
- $RubName=Array ("---------- SORTIES ----------","---------- LOISIRS ----------","---------- ETUDIANTS ----------","---------- SHOPPING ----------","---------- TOURISME ----------" );
- $Rub=Array ("sorties","loisirs","etudiants","shopping","tourisme" );
-
- For ($I=0;$I<5;$I++)
- {
- echo "<OPTION value=\"\">$RubName[$I]</OPTION>";
-
- $Query="SELECT ssrub from rubriques where rub like '$Rub[$I]'";
- $Result=MYSQL_QUERY ("$Query" );
- While ($Tab=MYSQL_FETCH_ROW ($Result))
- {
- echo "<OPTION value=\"$Tab[0]\">$Tab[0]</OPTION>\n";
- }
- echo "<OPTION value=\"\"></OPTION>";
- }
-
- ?>
-
- </select></p>
- <p>nom* : <input type="text" name="Nom"></p>
- <p>adresse* : <input type="text" name="Adresse"></p>
- <p>cp* : <input type="text" name="CP"></p>
- <p>ville* : <input type="text" name="Ville"></p>
- <p>tel* : <input type="text" name="Tel"></p>
- <p>fax : <input type="text" name="Fax"></p>
- <p>email : <input type="text" name="Email"></p>
- <p>url : <input type="text" name="Url"></p>
- <p>descript : <input type="text" name="Descript"></p>
- <p><input type="submit" name="Submit" value="Envoyer"> <input type="reset" name="Submit2" value="Rétablir"></p>
- </form>
- * : zones obligatoires
- </body>
- </html>
|
|