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 :

[JAVASCRIPT] passage d'argument à une fonction


Sujet :

JavaScript

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    801
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 801
    Points : 314
    Points
    314
    Par défaut [JAVASCRIPT] passage d'argument à une fonction
    Bonjour, Voilà mon problème est simple:
    Avec ce code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <input type=button value='changer' onclick=change(0,"V","VARIABLES GLOBALES","Gestion des mails"," Serveur de messagerie ","Mhost ","acnnt1")>
    J'ai l'erreur suivant:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Erreur, Constant chaîne non terminée.
    Je suis quasiment sur que ça vient des espaces dans les valeurs passés en arguments. Si ce n'est pas ça, qu'est ce que ça peut être ?
    Sinon, Comment règler le problème !!
    Merci de votre aide !!!

  2. #2
    Membre régulier
    Inscrit en
    Juin 2004
    Messages
    112
    Détails du profil
    Informations forums :
    Inscription : Juin 2004
    Messages : 112
    Points : 99
    Points
    99
    Par défaut
    quand tu mets ton onclick apres tu ouvres et tu fermes des "

    --> onClick="action..."

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    801
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 801
    Points : 314
    Points
    314
    Par défaut
    YEAHHHHHHHHHHHH
    ça marche !!!!!!!!!!!!!

    MERCI MERCI MERCI

  4. #4
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    47
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 47
    Points : 53
    Points
    53
    Par défaut Re: [JAVASCRIPT] passage d'argument à une fonction
    Comment règler le problème?

    1.Coder proprement
    2.Réfléchir:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <input type="button" value="changer" onclick="change(0,'V','VARIABLES GLOBALES','Gestion des mails',' Serveur de messagerie','Mhost','acnnt1');" />

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    801
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 801
    Points : 314
    Points
    314
    Par défaut
    Désolé pour mon manque de réflexion:
    Mais j'ai pas vu les " ", y en a bcp dans mon script.
    Envoilà une partie:
    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
     
    foreach(@Conf)
        {
              ~s/\s{2,}//g;
              ~s/\n//g;
              $index=substr($_,0,2);
              switch($index)
              {
                  case '#='
                  {
                      $html.="<\TABLE>\n";
                      ~s/#=//g;
                      ~s/={3,}/=/g;
                      $html.="<TABLE align='center'bgcolor=$color1 cellspacing=1 border=0>\n";
                      $html.="<TR height=30>\n";
                      $html.="<TD align='center' valign='middle' width=80% colspan=4>\n";
                      $html.="<p align='center'><font size=$size1 color=$textcolor1><B>$_<B></font></p>";
                      $html.="</TD>\n</TR>\n";
                      $Titre=$_;
                      $Titre=~s/\'||\||\(||\)||\=//g;
                      $Titre[0]=~s/\\/\//g;
                  }
                  case '#-'
                  {
                      ~s/#-||#//g;
                      $html.="<TR height=20 bgcolor=$color2>\n";
                      $html.="<TD align='left' valign='middle' width=100% colspan=4>\n";
                      $html.="<p align='Left'><font size=$size2 color=$textcolor2><B>$_</B></font></p>";
                      $html.="</TD>\n</TR>\n";
                      $SousTitre=$_;
                      $SousTitre=~s/\'||\||\(||\)||\-//g;
                      $SousTitre[0]=~s/\\/\//g;
                  }
                  case '#?'
                  {
                      ~s/#||\?//g;
                      $TypeValue=&DefineValue($_);
                      ~s/{(.*)//;
                      $html.="<TR height=10 bgcolor=$color3>\n";
                      $html.="<TD align='left' VALIGN='middle' width=100% colspan=4>\n";
                      $html.="<p align='left'><font size=$size3 color=$textcolor3><B><U><LI>$_</LI></U></B></font></p>";
                      $html.="</TD>\n</TR>\n";
                      $DefVariable=$_;
                      $DefVariable=~s/\'||\||\(||\)//g;
                      $DefVariable=~s/\\/\//g;
                  }
              }
              if(substr($_,0,1) eq '¤')
              {
                      ~s/¤//g;
     
                      @temp=split('->',$_);
                      $temp[0]=~s/\'||\||\(||\)//g;
                      $temp[0]=~s/\\/\//g;
                      $temp[1]=~s/\'||\||\(||\)//g;
                      $temp[1]=~s/\\/\//g;
                      $temp[0]=~s/_/ /g;
                      $html.="<TR height=10 bgcolor=$color4>\n";
                      $html.="<FORM name=\'f_$form\'>\n";
                      $html.="<TD align='left' valign='middle' width=100%>\n";
                      $html.="<p id=\'$form_0\' align='left><font size=$size4 color=$textcolor41><B>* $temp[0]</B></font></p>";
                      $html.="</TD>\n";
                      $html.="<TD align='left' valign='middle' width=100%>\n";
                      $html.="<p align='left' id=\'$form_1\'><font size=$size4 color=$textcolor42><B>$temp[1]</B></font></p>";
                      $html.="</TD>\n";
                      $html.="<input type='hidden' name=\'$form\_0\' value=$temp[0]><input type='hidden' name=\'$form\_1\' value=$temp[1]>";
                      $html.="<TD align='left' valign='middle' width=100%>\n";
                      $html.="<p align='left'><input type=button value='changer' onclick=\"change($form,\'$TypeValue\',\'$Titre\',\'$SousTitre\',\'$DefVariable\',\'$temp[0]\',\'$temp[1]\')\"></p>";
                      $html.="</TD>\n</FORM>\n</TR>\n";
              $form++;
              }
        }

  6. #6
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2005
    Messages
    47
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2005
    Messages : 47
    Points : 53
    Points
    53
    Par défaut
    Citation Envoyé par LE NEINDRE
    Désolé pour mon manque de réflexion:
    Mais j'ai pas vu les " ", y en a bcp dans mon script.
    Envoilà une partie:
    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
     
    foreach(@Conf)
        {
              ~s/\s{2,}//g;
              ~s/\n//g;
              $index=substr($_,0,2);
              switch($index)
              {
                  case '#='
                  {
                      $html.="<\TABLE>\n";
                      ~s/#=//g;
                      ~s/={3,}/=/g;
                      $html.="<TABLE align='center'bgcolor=$color1 cellspacing=1 border=0>\n";
                      $html.="<TR height=30>\n";
                      $html.="<TD align='center' valign='middle' width=80% colspan=4>\n";
                      $html.="<p align='center'><font size=$size1 color=$textcolor1><B>$_<B></font></p>";
                      $html.="</TD>\n</TR>\n";
                      $Titre=$_;
                      $Titre=~s/\'||\||\(||\)||\=//g;
                      $Titre[0]=~s/\\/\//g;
                  }
                  case '#-'
                  {
                      ~s/#-||#//g;
                      $html.="<TR height=20 bgcolor=$color2>\n";
                      $html.="<TD align='left' valign='middle' width=100% colspan=4>\n";
                      $html.="<p align='Left'><font size=$size2 color=$textcolor2><B>$_</B></font></p>";
                      $html.="</TD>\n</TR>\n";
                      $SousTitre=$_;
                      $SousTitre=~s/\'||\||\(||\)||\-//g;
                      $SousTitre[0]=~s/\\/\//g;
                  }
                  case '#?'
                  {
                      ~s/#||\?//g;
                      $TypeValue=&DefineValue($_);
                      ~s/{(.*)//;
                      $html.="<TR height=10 bgcolor=$color3>\n";
                      $html.="<TD align='left' VALIGN='middle' width=100% colspan=4>\n";
                      $html.="<p align='left'><font size=$size3 color=$textcolor3><B><U><LI>$_</LI></U></B></font></p>";
                      $html.="</TD>\n</TR>\n";
                      $DefVariable=$_;
                      $DefVariable=~s/\'||\||\(||\)//g;
                      $DefVariable=~s/\\/\//g;
                  }
              }
              if(substr($_,0,1) eq '¤')
              {
                      ~s/¤//g;
     
                      @temp=split('->',$_);
                      $temp[0]=~s/\'||\||\(||\)//g;
                      $temp[0]=~s/\\/\//g;
                      $temp[1]=~s/\'||\||\(||\)//g;
                      $temp[1]=~s/\\/\//g;
                      $temp[0]=~s/_/ /g;
                      $html.="<TR height=10 bgcolor=$color4>\n";
                      $html.="<FORM name=\'f_$form\'>\n";
                      $html.="<TD align='left' valign='middle' width=100%>\n";
                      $html.="<p id=\'$form_0\' align='left><font size=$size4 color=$textcolor41><B>* $temp[0]</B></font></p>";
                      $html.="</TD>\n";
                      $html.="<TD align='left' valign='middle' width=100%>\n";
                      $html.="<p align='left' id=\'$form_1\'><font size=$size4 color=$textcolor42><B>$temp[1]</B></font></p>";
                      $html.="</TD>\n";
                      $html.="<input type='hidden' name=\'$form\_0\' value=$temp[0]><input type='hidden' name=\'$form\_1\' value=$temp[1]>";
                      $html.="<TD align='left' valign='middle' width=100%>\n";
                      $html.="<p align='left'><input type=button value='changer' onclick=\"change($form,\'$TypeValue\',\'$Titre\',\'$SousTitre\',\'$DefVariable\',\'$temp[0]\',\'$temp[1]\')\"></p>";
                      $html.="</TD>\n</FORM>\n</TR>\n";
              $form++;
              }
        }
    J'ai quelques questions et remarques là...

    Elle font quoi au début de la page les paterns regxp ?
    Code proprement, comme je te l'ai dis.
    allez je prend au hazard une ligne:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $html.="<TD align='left' valign='middle' width=100%>\n";
    tu devrais la transformer en:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $html.='<td align="left" valign="middle" width="100%">' . "\n";
    [/code]

    Et perso, j'aurais même fais autrement encore:
    $html = array();
    $html[] = 'on rajoute une ligne';
    $html[] = 'on en rajoute une autre';
    $html = implode("\n", $html);

    mais bon...

  7. #7
    Membre averti
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    801
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 801
    Points : 314
    Points
    314
    Par défaut
    Je vais tâcher de suivre tes conseils car il est vrai que souvent je perds du temps à règler des bugs à cause de ma "non rigueur".

    N.B.: Les deux expressions régulières au départ font:
    - pour le première, suppression des espaces qd il y en a au moins deux d'affilé.
    - pour la seconde, suppression du retour chariot. Et oui, là je te sens venir, j'aurais déjà pu enlever le "g" à la fin de la seconde regexp et j'aurai aussi pu concaténer le tout en une i.e.:
    En tout cas merci pour tes remarques, elles me permettront d'être plus rigoureux.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Passage d'argument à une fonction
    Par free_01_binairy dans le forum Général JavaScript
    Réponses: 44
    Dernier message: 25/11/2014, 19h07
  2. Réponses: 4
    Dernier message: 29/04/2010, 06h30
  3. Passage de libelle à une fonction Javascript
    Par shaun_the_sheep dans le forum Général JavaScript
    Réponses: 13
    Dernier message: 25/04/2008, 16h41
  4. Réponses: 3
    Dernier message: 10/08/2007, 16h07
  5. Passer une fonction comme argument à une fonction
    Par Cocotier974 dans le forum Général Python
    Réponses: 4
    Dernier message: 29/06/2004, 13h41

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