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

ASP Discussion :

ASP et fonction javascript


Sujet :

ASP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    HiT
    HiT est déconnecté
    Débutant
    Inscrit en
    Juillet 2004
    Messages
    74
    Détails du profil
    Informations forums :
    Inscription : Juillet 2004
    Messages : 74
    Points : 20
    Points
    20
    Par défaut ASP et fonction javascript
    Bonjour,
    je souhaiterais insérer une fonction javascript dans une partie de code ASP. Il s'agit d'une fonction que je souhaiterais faire fonctionner lors du click sur le lien.
    le code asp est le suivant:
    Listoffilesfound= Listoffilesfound & "<TR><TD>" & TheTitle & "</TD><TD ALIGN=CENTER VALIGN=MIDDLE> <A HREF= " & Thefilep & " > View </A></TD><TD ALIGN=right VALIGN=MIDDLE><A target='_blank' HREF=" & Thefilep & " > View in a new window</A></td></TR>"
    je souhaiterais donc inserer ma fonction cacher() soit avec le href cacher(Thefilep), soit cacher() avec un onclick (la fonction marche avec et sans arguments). Le probleme est que je dois avoir des erreurs de "" car cela ne marche pas.
    Listoffilesfound= Listoffilesfound & "<TR><TD>" & TheTitle & "</TD><TD ALIGN=CENTER VALIGN=MIDDLE> <A HREF= " & Thefilep & " onclick='cacher()'> View </A></TD><TD ALIGN=right VALIGN=MIDDLE><A target='_blank' HREF=" & Thefilep & " > View in a new window</A></td></TR>"

  2. #2
    Membre actif
    Inscrit en
    Juin 2006
    Messages
    431
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 431
    Points : 209
    Points
    209
    Par défaut
    essaie en mettant onclick=""cacher()""

  3. #3
    HiT
    HiT est déconnecté
    Débutant
    Inscrit en
    Juillet 2004
    Messages
    74
    Détails du profil
    Informations forums :
    Inscription : Juillet 2004
    Messages : 74
    Points : 20
    Points
    20
    Par défaut
    pas d erreur signalée, mais cela ne marche pas. la fonction ne s'exécute pas
    aurais tu une autre idée?

  4. #4
    Membre actif
    Inscrit en
    Juin 2006
    Messages
    431
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 431
    Points : 209
    Points
    209
    Par défaut
    Il affiche ton lien correctement? tu le fais a quel moment dans ton code ton appel?
    tu es sur de ton code html?

  5. #5
    HiT
    HiT est déconnecté
    Débutant
    Inscrit en
    Juillet 2004
    Messages
    74
    Détails du profil
    Informations forums :
    Inscription : Juillet 2004
    Messages : 74
    Points : 20
    Points
    20
    Par défaut
    il affiche le lien sans problemes mais sans jouer le onclick.
    j'appelle ma fonction dans un tableau html de la facon suivante
    <TABLE BORDER=0 WIDTH=600>

    <% if Listoffilesfound="" then %>
    <TR><TD>The specified term or phrase was not found</TD></TR>
    <% else
    Response.Write (Listoffilesfound)
    end if %>

    </TABLE>

    je desespere et pourtant je pense que ce n'est qu une erreur de guillemets ou un detail
    Help

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    367
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2004
    Messages : 367
    Points : 414
    Points
    414
    Par défaut
    Salut,

    as tu essayé :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <A HREF= " & Thefilep & " onclick="" 'cacher()' "">
    deux doubles quotes avant la simple quote et deux apres. J'ai volontairement ajouté un espace pour la lisibilité.

  7. #7
    Membre actif
    Inscrit en
    Juin 2006
    Messages
    431
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 431
    Points : 209
    Points
    209
    Par défaut
    et avec:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Listoffilesfound & "<TR><TD>" & TheTitle & "</TD><TD ALIGN=""CENTER"" VALIGN=""MIDDLE""> <A HREF=" & Thefilep & " onclick=""cacher()""> View </A></TD><TD ALIGN=""right"" VALIGN=""MIDDLE""><A target=""_blank"" HREF=" & Thefilep & " > View in a new window</A></td></TR>"
    ?

    "" ' cacher()' "" ne devrait pas marccher gwenn, vu que ce n'est pas un script javascript à ce moment mais un appel html. Je me trompe?

  8. #8
    HiT
    HiT est déconnecté
    Débutant
    Inscrit en
    Juillet 2004
    Messages
    74
    Détails du profil
    Informations forums :
    Inscription : Juillet 2004
    Messages : 74
    Points : 20
    Points
    20
    Par défaut
    Microsoft VBScript compilation (0x800A03EA)
    Syntax error
    /AS400Asp/Zsearch.asp, line 246, column 17

    voici l erreur, la ligne 246 etant biensur celle que l on cherche á ecrire
    Pour ce qui est du navigateur, j'utilise IE...

  9. #9
    HiT
    HiT est déconnecté
    Débutant
    Inscrit en
    Juillet 2004
    Messages
    74
    Détails du profil
    Informations forums :
    Inscription : Juillet 2004
    Messages : 74
    Points : 20
    Points
    20
    Par défaut
    comme cela le code passe, tout s affiche mais la fonction n est pas joué....

    Listoffilesfound=Listoffilesfound & "<TR><TD>" & TheTitle & "</TD><TD
    ALIGN=""CENTER"" VALIGN=""MIDDLE""> <A HREF=" & Thefilep & " onclick=""cacher()""> View </A></TD><TD ALIGN=""right"" VALIGN=""MIDDLE""><A target=""_blank"" HREF=" & Thefilep & " > View in a new window</A></td></TR>"

  10. #10
    Membre actif
    Inscrit en
    Juin 2006
    Messages
    431
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 431
    Points : 209
    Points
    209
    Par défaut
    remontre ton tableau tel qu'il est actuellement.
    tu mets quoi comme chaine dans Listoffilesfound ?

  11. #11
    HiT
    HiT est déconnecté
    Débutant
    Inscrit en
    Juillet 2004
    Messages
    74
    Détails du profil
    Informations forums :
    Inscription : Juillet 2004
    Messages : 74
    Points : 20
    Points
    20
    Par défaut
    bon je vais copier tout le code meme s'il est long.
    Le principe de la fonction est une fonction de recherche style google qui va chercher dans les title des pages. Le principe est que la box pour rentrer le mot á chercher est dans une iframe elle meme dans une frame. Et j affiche la résultat dans une autre frame.
    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
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    <%@ Language=VBScript %>
    <% 
    DIM Listoffilesfound,Thefile,Thefolder,Folderpath,FileSystemObject
    Set FileSystemObject = Server.CreateObject("Scripting.FileSystemObject")
     
    if request.form="" then
       SendForm()
    else
    SearchTerm = Server.HTMLencode(request.form("term"))
    if Searchterm<>"" then
    SearchTermArray=Split(SearchTerm," ")
    MaxSearchTerms=ubound(SearchTermArray)
     
    Folderstosearch="\menus_new\newmenu"
    Folderstosearchasp="\..\as400asp"
    Folderstosearchp="\..\pageintranet"
     
     
    DonotsearchthisFiles =""
     
     
     
    Folderpath=server.mappath("\")
    ' Search folders
    If (FileSystemObject.FolderExists(Folderpath & Folderstosearch) = true) Then
    FolderstosearchArray=Split(Folderstosearch,",")
    Maxfolders=ubound(FolderstosearchArray)
    for i=0 to Maxfolders
    		Thefolder = FolderstosearchArray(i)
         Dim fs, f, f1, fc, s 
            Set fs = CreateObject("Scripting.FileSystemObject") 
     
            Set f = fs.GetFolder(Folderpath & Thefolder) 
            Set fc = f.Files 
            For Each f1 in fc
                 Wfile = f1.name 
    						 Thefile=Thefolder & "/" & Wfile
                 if (inStr(DonotsearchthisFiles,Thefile)=0 and (inStr(mid(Wfile,len(Wfile)-3,len(Wfile)),"htm")or inStr(mid(Wfile,len(Wfile)-3,len(Wfile)),"asp") or inStr(mid(Wfile,len(Wfile)-4,len(Wfile)),"html"))) then
     
                    		Searchit()
                 end if 
                        Next 
    next
    end if
     
    If (FileSystemObject.FolderExists(Folderpath & Folderstosearchasp) = true) Then
                 FolderstosearchArrayasp=Split(Folderstosearchasp,",")
    Maxfoldersasp=ubound(FolderstosearchArrayasp)
    for k=0 to Maxfoldersasp
    		Thefolderasp = FolderstosearchArrayasp(k)
         Dim fsasp, fasp, f1asp, fcasp, sasp 
            Set fsasp = CreateObject("Scripting.FileSystemObject") 
     
            Set fasp = fsasp.GetFolder(Folderpath & Thefolderasp) 
            Set fcasp = fasp.Files 
            For Each f1asp in fcasp 
                 Wfile = f1asp.name 
    						 Thefileasp=Thefolderasp & "/" & Wfile
                 if (inStr(DonotsearchthisFiles,Thefileasp)=0 and (inStr(mid(Wfile,len(Wfile)-3,len(Wfile)),"htm")or inStr(mid(Wfile,len(Wfile)-3,len(Wfile)),"asp") or inStr(mid(Wfile,len(Wfile)-4,len(Wfile)),"html"))) then
                  if inStr(Thefileasp,"Zsearch")= 0 then
                    		Searchitasp()
                    		end if
                 end if 
     
           Next 
    next
    end if
     
     
     
    	If (FileSystemObject.FolderExists(Folderpath & Folderstosearchp) = true) Then	
         Dim fsp, fp, f1p, fcp, sp 
            Set fsp = CreateObject("Scripting.FileSystemObject")
            Set fp = fsp.GetFolder(Folderpath) 
            Set fcp = fp.Files 
            For Each f1p in fcp 
                 Wfile = f1p.name 
    						 Thefilep=Folderstosearchp & "/" & Wfile
                 if (inStr(DonotsearchthisFiles,Thefilep)=0 and (inStr(mid(Wfile,len(Wfile)-3,len(Wfile)),"htm")or inStr(mid(Wfile,len(Wfile)-3,len(Wfile)),"asp") or inStr(mid(Wfile,len(Wfile)-4,len(Wfile)),"html"))) then
                    		 if inStr(Thefilep,"Zsearch")= 0 then
                    		Searchitp()
                    		end if
                 end if 
     
           Next 
    end if
     
    ' Write search results
    Searchresponse()
    end if
     
    end if
     %><% Sub SendForm() %>
     
    <HTML>
    <HEAD>
    <script>
    function cacher() {
    	//self.parent.parent.parent.parent.parent.document.body.rows="0,*";
    	alert ('ouais');
    	//window.top.document.body.rows ="0,*";	
     
    	top.document.body.rows ="0,*";
     
    	}
     
    	function cacherurl(url) {
     
    	top.document.body.rows ="0,*";
    	self.location.href=url;
     
    }
     
    function onenter(){
    	if(event.keyCode==13){
    	cacher();
    	}
    } 
    </script>
     
    <TITLE>Search</TITLE>
    </HEAD>
    <BODY BGCOLOR=FFFFFF ><CENTER>
    <form method="POST" action="Zsearch.asp" target="Cright" > 
     <table border=0 cellpadding=0 cellspacing=0 ><tr> 
     <td align=center> 
     <!--Enter term to search &nbsp;-->
     <input type=text name=term value="search menus" size=14 onkeypress="Javascript:onenter();">
     <input name=submit type=image SRC="iseek.gif" ALT="search" value="search" onclick="javascript:cacher();">
     </td> 
     </tr>
      <tr >
     <IMG SRC="searchmac.jpg">
     </tr>
     </table> 
     </form>
     
     
    </CENTER></BODY></HTML>
    <% End Sub %>
    <% Sub Searchresponse() %>
    <HTML>
    <HEAD>
    <TITLE>Search results</TITLE>
    </HEAD>
    <BODY BGCOLOR=FFFFFF ><CENTER> 
     
    <TABLE BORDER=0 WIDTH=600><TR><TD BGCOLOR=C0C0C0><FONT SIZE=5><B>Search Results</B></FONT></TD></TR></TABLE>  
     
    <TABLE BORDER=0 WIDTH=600>
     
      <% if Listoffilesfound="" then %>
        <TR><TD>The specified term or phrase was not found</TD></TR> 
      <% else 
        Response.Write (Listoffilesfound)  
      end if %>
     
    </TABLE> 
     
    <TABLE BORDER=0 WIDTH=600><TR><TD BGCOLOR=C0C0C0 ALIGN=RIGHT><FONT SIZE=1>Search utility provided by Page Aerospace</A></FONT></TD></TR></TABLE> 
     
    </CENTER></BODY></HTML> 
     
    <% End Sub %>
     
    <% Sub Searchit() 
    if inStr(Thefile,"Zsearch.asp")=false then
    Thefilepath=Folderpath & Thefile
    Set fs = CreateObject("Scripting.FileSystemObject") 
    Set a = fs.OpenTextFile(Thefilepath) 
    ThecontentofFile = a.ReadAll 
    a.close 
    'ThecontentofFile=notag(ThecontentofFile)
     
    Findterms=0
    for j=0 to MaxSearchTerms
       if instr(1,ThecontentofFile,"</title>",1)>0 and instr(1,ThecontentofFile,"<title>",1)>0 then  
          TheTitle=left(ThecontentofFile,instr(1,ThecontentofFile,"</title>",1)-1)      
          TheTitle=right(TheTitle,len(TheTitle)-instr(1,TheTitle,"<title>",1)-6) 
       end if
     if instr(1,Thetitle,SearchTermArray(j),1)>0 then 
    		Findterms=Findterms+1
     end if
    next
     
    if Findterms=MaxSearchTerms+1 then 
     
     
    'Listoffilesfound= Listoffilesfound & "<TR><TD>" & TheTitle  & "</TD><TD ALIGN=CENTER VALIGN=MIDDLE> <A HREF= " & Thefile & " onClick=\'cacher()\' > View </A></TD><TD ALIGN=right VALIGN=MIDDLE><A target='_blank' HREF=" & Thefile & " > View in a new window</A></td></TR>" 
     
    end if
    end if
     
     End Sub %>
     
     <% Sub Searchitasp() 
     if inStr(Thefileasp,"Zsearch")= 0 then
    Thefilepath=Folderpath & Thefileasp
    Set fs = CreateObject("Scripting.FileSystemObject") 
    Set a = fs.OpenTextFile(Thefilepath) 
    ThecontentofFile = a.ReadAll 
    a.close 
    'ThecontentofFile=notag(ThecontentofFile)
     
    Findterms=0
    for j=0 to MaxSearchTerms
       if instr(1,ThecontentofFile,"</title>",1)>0 and instr(1,ThecontentofFile,"<title>",1)>0 then  
          TheTitle=left(ThecontentofFile,instr(1,ThecontentofFile,"</title>",1)-1)      
          TheTitle=right(TheTitle,len(TheTitle)-instr(1,TheTitle,"<title>",1)-6) 
       end if
     if instr(1,Thetitle,SearchTermArray(j),1)>0 then 
    		Findterms=Findterms+1
     end if
    next
     
    if Findterms=MaxSearchTerms+1 then 
     
     
    Listoffilesfound= Listoffilesfound & "<TR><TD>" & TheTitle  & "</TD><TD ALIGN=CENTER VALIGN=MIDDLE> <A  HREF=" & Thefileasp & " > View </A></TD><TD ALIGN=right VALIGN=MIDDLE><A target='_blank' HREF=" & Thefileasp & " > View in a new window</A></td></TR>" 
    end if
    end if
     
     End Sub %>
     
      <% Sub Searchitp() 
    Thefilepath=Folderpath & Thefilep
    Set fs = CreateObject("Scripting.FileSystemObject") 
    Set a = fs.OpenTextFile(Thefilepath) 
    ThecontentofFile = a.ReadAll 
    a.close 
    'ThecontentofFile=notag(ThecontentofFile)
     
    Findterms=0
    for j=0 to MaxSearchTerms
       if instr(1,ThecontentofFile,"</title>",1)>0 and instr(1,ThecontentofFile,"<title>",1)>0 then  
          TheTitle=left(ThecontentofFile,instr(1,ThecontentofFile,"</title>",1)-1)      
          TheTitle=right(TheTitle,len(TheTitle)-instr(1,TheTitle,"<title>",1)-6) 
       end if
     if instr(1,Thetitle,SearchTermArray(j),1)>0 then 
    		Findterms=Findterms+1
     end if
    next
     
    if Findterms=MaxSearchTerms+1 then 
     
    Listoffilesfound=Listoffilesfound & "<TR><TD>" & TheTitle & "</TD><TD ALIGN=""CENTER"" VALIGN=""MIDDLE""> <A HREF=" & Thefilep & " onclick=""cacher()""> View </A></TD><TD ALIGN=""right"" VALIGN=""MIDDLE""><A target=""_blank"" HREF=" & Thefilep & " > View in a new window</A></td></TR>"
    'Listoffilesfound= Listoffilesfound & "<TR><TD>" & TheTitle  & "</TD><TD ALIGN=CENTER VALIGN=MIDDLE> <A HREF=" & Thefileasp & "  > View </A></TD><TD ALIGN=right VALIGN=MIDDLE><A target='_blank' HREF=" & Thefilep & " > View in a new window</A></td></TR>" 
     
     
    end if
     
     End Sub %>

  12. #12
    Membre actif
    Inscrit en
    Juin 2006
    Messages
    431
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 431
    Points : 209
    Points
    209
    Par défaut
    argh utilise la balise code

  13. #13
    HiT
    HiT est déconnecté
    Débutant
    Inscrit en
    Juillet 2004
    Messages
    74
    Détails du profil
    Informations forums :
    Inscription : Juillet 2004
    Messages : 74
    Points : 20
    Points
    20
    Par défaut
    voila j ai modifié le mesage en utilisant la balise

  14. #14
    Membre actif
    Inscrit en
    Juin 2006
    Messages
    431
    Détails du profil
    Informations forums :
    Inscription : Juin 2006
    Messages : 431
    Points : 209
    Points
    209
    Par défaut
    c'est pas mais C'est pas la que tu as une erreur?

Discussions similaires

  1. Appeler une fonction JavaScript (en ASP) ?
    Par sperron dans le forum ASP
    Réponses: 25
    Dernier message: 12/02/2010, 09h46
  2. asp:hyperlink + fonction javascript
    Par pigeon11 dans le forum ASP.NET
    Réponses: 8
    Dernier message: 07/04/2009, 11h31
  3. page asp et fonction javascript
    Par bozykely3 dans le forum ASP
    Réponses: 1
    Dernier message: 09/06/2007, 10h26
  4. asp et fonction javascript
    Par philippe123 dans le forum ASP
    Réponses: 2
    Dernier message: 08/08/2005, 13h47
  5. Réponses: 5
    Dernier message: 13/08/2004, 15h40

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