IdentifiantMot de passe
Loading...
Mot de passe oubli� ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les r�ponses en temps r�el, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

fonction javascript et onsubmit sur une page


Sujet :

JavaScript

  1. #1
    Membre confirm�
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    86
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 86
    Par d�faut fonction javascript et onsubmit sur une page
    Bonjour

    Ci joint mon script je precise que je ne connais pas la programmation en Javasript.

    Voil� donc mon PB ci joint le code

    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
     
    <?php  
     
    if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1") ) { // enregistrement des données
     
     
    } // fin de l'enregistrement des données
     
     
    ?>
     
    <script type='text/javascript'>
    //<![CDATA[
    var geocoder = null;
     
    function AfficherAdresse(addresse,lon_ad,la_ad,com_ad) {
    	if  (geocoder) {
    		geocoder.getLatLng(
    			addresse,
    			function(point) {
    				if (!point) {
    					alert('Impossible de geolocaliser cette adresse'+addresse+com_ad+cp);
    				} else {
    					MaCarte.addControl(new GMapTypeControl());
    					MaCarte.addControl(new GOverviewMapControl());
    					MaCarte.addControl(new GLargeMapControl());
    					var marker = new GMarker(point, {draggable: true});
    					GEvent.addListener(marker, 'dragstart', function() {
    						MaCarte.closeInfoWindow();
    					});
    					GEvent.addListener(marker, 'dragend', function(point) {
    						AfficheGPS(marker);
    					});
    					MaCarte.addOverlay(marker);
    					AfficheGPS(marker);
    					MaCarte.setCenter(point, 15);
    				}
    			}
    		);
    	}
    }
    //]]>
    </script>
    <html>
    <head>
    <script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAD_snjZhIrbGNNRZrIdrTARSOQON08a6Pxfkjf9mWq3Ul" type="text/javascript"></script>
    <meta http-equiv="Content-Language" content="fr,ca">
    <link type="text/css" rel="stylesheet" href="../style.css">
    </head>
    <body onLoad="load() " onUnload="GUnload()" bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <!-- ImageReady Slices (gpsevasion_v3.psd) -->
    <table width="802" height="86" border="0" align="center" cellpadding="0" cellspacing="0" id="Tableau_01">
      <tr> 
        <td width="823" height="32" align="center" valign="top"> <div align="center"> 
            <?php if (!isset($_POST['enregistrer'])){ // affichage fichier ?>
            <form method="post" name="creation_poi" id="creation_poi" action="poi_proposition_visiteur_beta.php" onsubmit="AfficherAdresse(this.ad_ad.value,this.lon_ad.value,this.la_ad.value,what.value); return false">
              <table width="100%" border="0">
                <tr> 
    			  <td width="43%" align="center" valign="top"><div id="EmplacementDeMacarte" style="width: 350px; height: 360px"></div></td>
    			  <td width="57%" height="345" align="center" valign="top"> <table width="100%" align="center">
                      <tr> 
                        <td colspan="3" class="Tableau_titre"><div align="center"><? echo $tx_titre14 ?></div></td>
                      </tr>
                      <tr valign="baseline"> 
                        <td width="22%" align="right" nowrap class="Tableau_corps"><div align="right"><? echo "$tx_form3" ; ?></div></td>
                        <td colspan="2" class="Tableau_corps"> <input name="nom_ad" type="text" class="Boite" value="<? echo $_SESSION['nom_ad'] ?>" size="60"> 
                        </td>
                      </tr>
                      <tr valign="baseline"> 
                        <td height="24" colspan="3" align="right" nowrap class="Tableau_corps"> 
                          <div align="right"> 
                            <table width="102%" border="1" cellspacing="0" bordercolor="#FF0000" class="Tableau_corps">
                              <tr> 
                                <td colspan="4"><div align="center" id="message"></div></td>
                              </tr>
                            </table>
                            <input name="position_lonla" type="submit" class="bouton" value="Localisation (long/lat)"  onClick="what=this" >
                          </div></td>
                      </tr>
                      <tr> 
                        <td colspan="3" class="Tableau_titre"><div align="center"><? echo $tx_titre15 ?></div></td>
                      </tr>
                      <tr valign="baseline"> 
                        <td align="right" nowrap class="Tableau_corps"><div align="right"><? echo "$tx_form4" ; ?></div></td>
                        <td width="55%" class="Tableau_corps"><input name="ad_ad" type="text" class="Boite" value="<? echo $_SESSION['ad_ad'] ?>" size="60"></td>
                        <td width="23%" align="center" valign="middle" class="Tableau_corps"><input name="position_ad" type="submit" class="bouton" value="Localisation (adresse)"  onClick="what=this" ></td>
                      </tr>
                      <tr valign="baseline"> 
                        <td height="22" align="right" nowrap class="Tableau_corps">&nbsp;</td>
                        <td colspan="2" class="Tableau_corps"><input name="enregistrer" type="submit" class="bouton" value="Proposer (adresse)"  ></td>
                      </tr>
                    </table></td>
                </tr>
              </table>
              <p> 
              </p>
              <p> 
                <input type="hidden" name="MM_insert" value="form1">
                <input type="hidden" name="m" value="1">
              </p>
            </form>
            <p>&nbsp;</p>
            <? } ?>
            <?php if (isset($_POST['enregistrer'])){ // affichage fichier ?>
            <table width="52%" border="0" align="center">
              <tr> 
                <td class="Tableau_titre"><div align="center"><? echo $tx_titre16 ?></div></td>
              </tr>
              <tr> 
                <td height="64" class="Tableau_corps"> <div align="center"> 
                    <p class="right">&nbsp;</p>
                    <p class="right"><a href="../poi_proposition_visiteur.php"><? echo "$tx_form16" ; ?></a></p>
                    <p class="right"><a href="../index.php"><? echo "$tx_form17" ; ?></a></p>
                    <p class="right">&nbsp;</p>
                  </div></td>
              </tr>
              <tr> 
                <td class="Tableau_corps"><div align="center"></div></td>
              </tr>
            </table>
            <p>&nbsp;</p>
            <? } ?>
            <p>&nbsp;</p>
          </div></td>
      </tr>
    </table>
    <!-- End ImageReady Slices -->
    </body>
    </html>
    J�ai une feuille avec une carte google , mon visiteur saisie une adresse ou une longitude et latitude.

    En cliquant sur le bouton � v�rifier adresse � ou � v�rifier lon/la � il lance la fonction � AfficherAdresse � et positionne cette derniere sur la carte.

    Je pense qu a ce niveau �a marche.

    Une fois l�adresse correctement positionner je souhaite enregistrer dans ma base donn�es les infos en cliquant sur le bouton � Proposer (adresse) � de facon classique en php

    Et la ca ne marche pas je relance la fonction � AfficherAdresse � comme je ne connais pas javascript je dois louper des choses

    Pouvez vous me donner un coup de main pour votre info voir la page de test

    http://www.gps-evasion.com/_rep1/poi...iteur_beta.php

    merci pour votre aide

  2. #2
    Invit�
    Invit�(e)
    Par d�faut
    Bonjour,

    Ton bouton
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
     
    <input name="enregistrer" type="submit" class="bouton" value="Proposer (adresse)"  >
    soumet ton formulaire, donc comme :
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
     
    <form method="post" name="creation_poi" id="creation_poi" action="poi_proposition_visiteur_beta.php" onsubmit="AfficherAdresse(this.ad_ad.value,this.lon_ad.value,this.la_ad.value,what.value); return false">
    Tu as mis sur l'�v�ment onsubmit, l'appelle � AfficherAdresse(this.ad_ad.value,this.lon_ad.value,this.la_ad.value,what.value); return false" et que tu retourne FALSE, donc ton formulaire ne fera pas l'action action="poi_proposition_visiteur_beta.php" mais seulemnt que de lancer AfficherAdresse(...)

    Enfin je pense

    Tu peux cr�er un autre bouton standard qui sur onclick lancera AfficherAdresse(...) et tu enl�ve le onsubmit du form

    A+

  3. #3
    Membre confirm�
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    86
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 86
    Par d�faut
    merci je vais tester ton analyse

    peux tu me donner la syntaxe afin d'etre sur

    merci

  4. #4
    Expert �minent

    Homme Profil pro
    Inscrit en
    Janvier 2007
    Messages
    13 474
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Is�re (Rh�ne Alpes)

    Informations professionnelles :
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2007
    Messages : 13 474
    Par d�faut
    Bonjour,
    Citation Envoy� par gpsevasion Voir le message
    peux tu me donner la syntaxe afin d'etre sur
    il suffit d'enlever le "return false" ...

    A+

  5. #5
    Invit�
    Invit�(e)
    Par d�faut
    Bonjour, cela est vrai E.Bzz

    Cependant, la fonction AfficherAdresse (...) devrait �tre utilis�e par les boutons "Localisation" voir image.



    Il faudrait leur mettre un type="button" et un onclick avec l'appel � la fonction et les bons param�tres. Ainsi, dans le form, il pourra �tre supprim� le onsubmit, le form fera donc son office pour transmettre les param�tres n�cessaire au script qui va bien.

    Bon, je peux me tromper

    A+

  6. #6
    Expert �minent

    Homme Profil pro
    Inscrit en
    Janvier 2007
    Messages
    13 474
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Is�re (Rh�ne Alpes)

    Informations professionnelles :
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2007
    Messages : 13 474
    Par d�faut
    Citation Envoy� par jlmag Voir le message
    Cependant, la fonction AfficherAdresse (...) devrait �tre utilis�e par les boutons "Localisation" voir image.
    Je n'ai pas eu le temps de regarder autant en d�tail

    A+

  7. #7
    Membre confirm�
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    86
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 86
    Par d�faut
    merci pour votre aide je regarde le script et je vous tiens au courant

  8. #8
    Membre confirm�
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    86
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 86
    Par d�faut
    merci pour votre aide comme toujours tres efficace

    voila la soluc




    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
     
    <?php  
     
    if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1") ) { // enregistrement des données
     
     
    } // fin de l'enregistrement des données
     
     
    ?>
     
    <script type='text/javascript'>
    //<![CDATA[
    var geocoder = null;
     
    function AfficherAdresse(addresse,lon_ad,la_ad,com_ad) {
    	if  (geocoder) {
    		geocoder.getLatLng(
    			addresse,
    			function(point) {
    				if (!point) {
    					alert('Impossible de geolocaliser cette adresse'+addresse+com_ad+cp);
    				} else {
    					MaCarte.addControl(new GMapTypeControl());
    					MaCarte.addControl(new GOverviewMapControl());
    					MaCarte.addControl(new GLargeMapControl());
    					var marker = new GMarker(point, {draggable: true});
    					GEvent.addListener(marker, 'dragstart', function() {
    						MaCarte.closeInfoWindow();
    					});
    					GEvent.addListener(marker, 'dragend', function(point) {
    						AfficheGPS(marker);
    					});
    					MaCarte.addOverlay(marker);
    					AfficheGPS(marker);
    					MaCarte.setCenter(point, 15);
    				}
    			}
    		);
    	}
    }
    //]]>
    </script>
    <html>
    <head>
    <script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAAD_snjZhIrbGNNRZrIdrTARSOQON08a6Pxfkjf9mWq3Ul" type="text/javascript"></script>
    <meta http-equiv="Content-Language" content="fr,ca">
    <link type="text/css" rel="stylesheet" href="../style.css">
    </head>
    <body onLoad="load() " onUnload="GUnload()" bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <!-- ImageReady Slices (gpsevasion_v3.psd) -->
    <table width="802" height="86" border="0" align="center" cellpadding="0" cellspacing="0" id="Tableau_01">
      <tr> 
        <td width="823" height="32" align="center" valign="top"> <div align="center"> 
            <?php if (!isset($_POST['enregistrer'])){ // affichage fichier ?>
            <form method="post" name="creation_poi" id="creation_poi" action="poi_proposition_visiteur_beta.php" >
              <table width="100%" border="0">
                <tr> 
    			  <td width="43%" align="center" valign="top"><div id="EmplacementDeMacarte" style="width: 350px; height: 360px"></div></td>
    			  <td width="57%" height="345" align="center" valign="top"> <table width="100%" align="center">
                      <tr> 
                        <td colspan="3" class="Tableau_titre"><div align="center"><? echo $tx_titre14 ?></div></td>
                      </tr>
                      <tr valign="baseline"> 
                        <td width="22%" align="right" nowrap class="Tableau_corps"><div align="right"><? echo "$tx_form3" ; ?></div></td>
                        <td colspan="2" class="Tableau_corps"> <input name="nom_ad" type="text" class="Boite" value="<? echo $_SESSION['nom_ad'] ?>" size="60"> 
                        </td>
                      </tr>
                      <tr valign="baseline"> 
                        <td height="24" colspan="3" align="right" nowrap class="Tableau_corps"> 
                          <div align="right"> 
                            <table width="102%" border="1" cellspacing="0" bordercolor="#FF0000" class="Tableau_corps">
                              <tr> 
                                <td colspan="4"><div align="center" id="message"></div></td>
                              </tr>
                            </table>
                          <input name="position_lonla" type="button" class="bouton" value="Localisation (long/lat)"  onclick="AfficherAdresse(document.creation_poi.ad_ad.value,document.creation_poi.lon_ad.value,document.creation_poi.la_ad.value)" >
                          </div></td>
                      </tr>
                      <tr> 
                        <td colspan="3" class="Tableau_titre"><div align="center"><? echo $tx_titre15 ?></div></td>
                      </tr>
                      <tr valign="baseline"> 
                        <td align="right" nowrap class="Tableau_corps"><div align="right"><? echo "$tx_form4" ; ?></div></td>
                        <td width="55%" class="Tableau_corps"><input name="ad_ad" type="text" class="Boite" value="<? echo $_SESSION['ad_ad'] ?>" size="60"></td>
                        <td width="23%" align="center" valign="middle" class="Tableau_corps">
                          <input name="position_ad" type="button" class="bouton" value="Localisation (adresse)"  onclick="AfficherAdresse(document.creation_poi.ad_ad.value,document.creation_poi.lon_ad.value,document.creation_poi.la_ad.value)" >
                      </tr>
                      <tr valign="baseline"> 
                        <td height="22" align="right" nowrap class="Tableau_corps">&nbsp;</td>
                        <td colspan="2" class="Tableau_corps"><input name="enregistrer" type="submit" class="bouton" value="Proposer (adresse)"  ></td>
                      </tr>
                    </table></td>
                </tr>
              </table>
              <p> 
              </p>
              <p> 
                <input type="hidden" name="MM_insert" value="form1">
                <input type="hidden" name="m" value="1">
              </p>
            </form>
            <p>&nbsp;</p>
            <? } ?>
            <?php if (isset($_POST['enregistrer'])){ // affichage fichier ?>
            <table width="52%" border="0" align="center">
              <tr> 
                <td class="Tableau_titre"><div align="center"><? echo $tx_titre16 ?></div></td>
              </tr>
              <tr> 
                <td height="64" class="Tableau_corps"> <div align="center"> 
                    <p class="right">&nbsp;</p>
                    <p class="right"><a href="../poi_proposition_visiteur.php"><? echo "$tx_form16" ; ?></a></p>
                    <p class="right"><a href="../index.php"><? echo "$tx_form17" ; ?></a></p>
                    <p class="right">&nbsp;</p>
                  </div></td>
              </tr>
              <tr> 
                <td class="Tableau_corps"><div align="center"></div></td>
              </tr>
            </table>
            <p>&nbsp;</p>
            <? } ?>
            <p>&nbsp;</p>
          </div></td>
      </tr>
    </table>
    <!-- End ImageReady Slices -->
    </body>
    </html>

+ R�pondre � la discussion
Cette discussion est r�solue.

Discussions similaires

  1. R�ponses: 3
    Dernier message: 09/11/2010, 19h31
  2. [DOM] Appeler une fonction javascript se trouvant sur une autre page
    Par monstor dans le forum G�n�ral JavaScript
    R�ponses: 6
    Dernier message: 04/09/2008, 11h11
  3. [Javascript] rediriger sur une page en javascript
    Par tioseb dans le forum G�n�ral JavaScript
    R�ponses: 4
    Dernier message: 15/02/2006, 14h55
  4. javascript sur une page creation flash mx
    Par hadjplasma dans le forum G�n�ral JavaScript
    R�ponses: 3
    Dernier message: 17/08/2005, 12h06
  5. comment rediriger sur une page html en fonction de la langue
    Par pierrot10 dans le forum Balisage (X)HTML et validation W3C
    R�ponses: 2
    Dernier message: 10/08/2005, 11h42

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo