Visualizzazione dei risultati da 1 a 8 su 8
  1. #1

    sostituzione spazi in un form con %

    come posso fare che gli spazi in una casella di testo di un form vegano sostituiti dal carattere %

  2. #2
    replace("ciao ciao", " ", "%")

    ottieni

    ciao%ciao

  3. #3

    ma in un form di questo genere mi passa sempre i soliti dati come lo modifico ?

    <td><form action="result.asp" name="ricerca" id="ricerca">
    <table width="110" border="1" align="center" cellpadding="1" cellspacing="0" bordercolor="#99CC33">
    <tr>
    <td bordercolor="#000000"><span class="colonna_nera_2">Ricerca:</span></td>
    </tr>
    <tr>
    <td bordercolor="#000000" class="colonna_nera">Cerca nel testo
    </td>
    </tr>
    <tr>
    <td bordercolor="#000000" class="colonna_nera"><input name="ricerca" type="text" id="ricerca" onClick="replace(&quot;ciao ciao&quot;, &quot; &quot;, &quot;%&quot
    " size="18"></td>
    </tr>
    <tr>
    <td height="24" bordercolor="#000000"><input type="submit" name="Submit" value="Cerca">
    </td>
    </tr>
    </table>

    </form></td>

  4. #4
    per prima cosa nel <form> non hai specificato il method qundi usa get per default

    se lo lasci con get allora scrivi

    replace(request.querystring("ricerca"), " ", "%")

    se usi il metodo post scrivi

    replace(request.form("ricerca"), " ", "%")

  5. #5
    dopo aver trasmesso i dati del form ed averli acquisiti nella pagina di destinazione con request.form applichi il replace!

    ricerca = request.form("ricerca")
    ricerca = replace(ricerca," ","%")

  6. #6

    non funziona perche il file del form e il file di destinazione sono sullo stesso file

    come lo posso modificare

    codice:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    
    <%
    Dim contrappunti__MMColParam
    contrappunti__MMColParam = "%"
    If (Request.Form("ricerca")  <> "") Then 
      contrappunti__MMColParam = Request.Form("ricerca") 
      ricerca = replace(ricerca," ","%")
      End If
    
    %>
    <%
    Dim contrappunti__MMColDataini
    contrappunti__MMColDataini = "1"
    If (Request.Form("dataini")   <> "") Then 
      contrappunti__MMColDataini = Request.Form("dataini")  
    End If
    %>
    <%
    Dim contrappunti__MMColDatafin
    contrappunti__MMColDatafin = "99999999"
    If (Request.Form("datafin")     <> "") Then 
      contrappunti__MMColDatafin = Request.Form("datafin")    
    End If
    %>
    <%
    Dim contrappunti
    Dim contrappunti_numRows
    
    Set contrappunti = Server.CreateObject("ADODB.Recordset")
    contrappunti.ActiveConnection = MM_database_STRING
    contrappunti.Source = "SELECT *  FROM contributo, data  WHERE (data_pubblicazione <= data) and (data_pubblicazione >= " + Replace(contrappunti__MMColDataini, "'", "''") + " AND data_pubblicazione <= " + Replace(contrappunti__MMColDatafin, "'", "''") + ") AND (snodo=1) and (autore LIKE '%" + Replace(contrappunti__MMColParam, "'", "''") + "%' or titolo LIKE '%" + Replace(contrappunti__MMColParam, "'", "''") + "%' or sottotitolo LIKE '%" + Replace(contrappunti__MMColParam, "'", "''") + "%' or sintesi LIKE '%" + Replace(contrappunti__MMColParam, "'", "''") + "%' or testocompleto LIKE '%" + Replace(contrappunti__MMColParam, "'", "''") + "%' or soggetto LIKE '%" + Replace(contrappunti__MMColParam, "'", "''") + "%' or keyworks LIKE '%" + Replace(contrappunti__MMColParam, "'", "''") + "%' )  ORDER BY contributo.data_pubblicazione DESC;"
    contrappunti.CursorType = 0
    contrappunti.CursorLocation = 2
    contrappunti.LockType = 1
    contrappunti.Open()
    
    contrappunti_numRows = 0
    %>
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index
    
    Repeat1__numRows = 10
    Repeat1__index = 0
    contrappunti_numRows = contrappunti_numRows + Repeat1__numRows
    %>
    
    <%
    Dim MM_paramName 
    %>
    <%
    ' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
    
    Dim MM_keepNone
    Dim MM_keepURL
    Dim MM_keepForm
    Dim MM_keepBoth
    
    Dim MM_removeList
    Dim MM_item
    Dim MM_nextItem
    
    ' create the list of parameters which should not be maintained
    MM_removeList = "&index="
    If (MM_paramName <> "") Then
      MM_removeList = MM_removeList & "&" & MM_paramName & "="
    End If
    
    MM_keepURL=""
    MM_keepForm=""
    MM_keepBoth=""
    MM_keepNone=""
    
    ' add the URL parameters to the MM_keepURL string
    For Each MM_item In Request.QueryString
      MM_nextItem = "&" & MM_item & "="
      If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
        MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
      End If
    Next
    
    ' add the Form variables to the MM_keepForm string
    For Each MM_item In Request.Form
      MM_nextItem = "&" & MM_item & "="
      If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
        MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
      End If
    Next
    
    ' create the Form + URL string and remove the intial '&' from each of the strings
    MM_keepBoth = MM_keepURL & MM_keepForm
    If (MM_keepBoth <> "") Then 
      MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
    End If
    If (MM_keepURL <> "")  Then
      MM_keepURL  = Right(MM_keepURL, Len(MM_keepURL) - 1)
    End If
    If (MM_keepForm <> "") Then
      MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
    End If
    
    ' a utility function used for adding additional parameters to these strings
    Function MM_joinChar(firstItem)
      If (firstItem <> "") Then
        MM_joinChar = "&"
      Else
        MM_joinChar = ""
      End If
    End Function
    %>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="stile.css" rel="stylesheet" type="text/css">
    </head>
    
    <body>
    <table width="785" height="100%"  border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="115" valign="top" bgcolor="#000000"><table width="115" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td>[img]img/logo.gif[/img]</td>
          </tr>
          <tr>
            <td align="center">[img]img/forum.gif[/img]</td>
          </tr>
          <tr>
            <td align="center"><table width="110" border="1" align="center" cellpadding="1" cellspacing="0" bordercolor="#99CC33">
              <tr>
                <td bordercolor="#000000"><span class="colonna_nera_2">Legenda:</span></td>
              </tr>
              <tr>
                <td bordercolor="#000000" class="colonna_nera">Il contributo
    
                  contiene allegati
    
                  in formato:</td>
              </tr>
              <tr>
                <td bordercolor="#000000"><table width="102" border="0" cellspacing="0" cellpadding="1">
                  <tr>
                    <td width="16" height="16">[img]../img/link.gif[/img]</td>
                    <td class="colonna_nera">Link</td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td bordercolor="#000000"><table width="102" border="0" cellspacing="0" cellpadding="1">
                  <tr>
                    <td width="16" height="16">[img]../img/doc.gif[/img]</td>
                    <td class="colonna_nera">Testo</td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td bordercolor="#000000"><table width="102" border="0" cellspacing="0" cellpadding="1">
                  <tr>
                    <td width="16" height="16">[img]../img/video.gif[/img]</td>
                    <td class="colonna_nera">Video</td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td bordercolor="#000000"><table width="102" border="0" cellspacing="0" cellpadding="1">
                  <tr>
                    <td width="16" height="16">[img]../img/audio.gif[/img]</td>
                    <td class="colonna_nera">Audio</td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td bordercolor="#000000"><table width="102" border="0" cellspacing="0" cellpadding="1">
                  <tr>
                    <td width="16" height="16">[img]../img/img.gif[/img]</td>
                    <td class="colonna_nera">Immagini</td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td height="5"></td>
          </tr>
          <tr>
    	         <td><form action="result.asp" name="ricerca" id="ricerca">
                  <table width="110" border="1" align="center" cellpadding="1" cellspacing="0" bordercolor="#99CC33">
                    <tr> 
                      <td bordercolor="#000000"><span class="colonna_nera_2">Ricerca:</span></td>
                    </tr>
                    <tr> 
                      <td bordercolor="#000000" class="colonna_nera">Cerca nel testo 
                      </td>
                    </tr>
                    <tr> 
                      <td bordercolor="#000000" class="colonna_nera"><input name="ricerca" type="text" id="ricerca" size="18"></td>
                    </tr>
                    <tr> 
                      <td height="24" bordercolor="#000000"><input type="submit" name="Submit" value="Cerca"> 
                      </td>
                    </tr>
                  </table>
                
                </form></td>
    			      </tr>
          <tr>
            <td height="5">		</td>
          </tr>
        </table></td>
        <td width="670" valign="top"><table width="670" border="0" cellspacing="0" cellpadding="0">
            <tr>
            <td height="17"></td>
          </tr>
          <tr>
            <td><table width="665" height="41" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="462" height="41">[img]img/scritta.gif[/img]</td>
                <td height="41">[img]img/i.gif[/img]</td>
                <td height="41">[img]img/p.gif[/img]</td>
                <td height="41">[img]img/r.gif[/img]</td>
                <td height="41">[img]img/e.gif[/img]</td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td>[img]img/descr.gif[/img]</td>
          </tr>
            <% 
    While ((Repeat1__numRows <> 0) AND (NOT contrappunti.EOF)) 
    %>
            <tr> 
              <td>
     
                <table width="660" border="1" align="center" cellpadding="0" cellspacing="1" bordercolor="#FFFFFF">
                  <tr> 
                    <td bordercolor="#A6C030" bgcolor="#A6C030"><table width="652" border="0" align="center" cellpadding="1" cellspacing="0">
                        <tr> 
                          <td height="18" class="titolo_contributo"><%=(contrappunti.Fields.Item("titolo").Value)%></td>
                          <td width="120" height="18" align="center">
    					  [img]../img/<%=(contrappunti.Fields.Item([/img]" name="Link" width="20" height="16" id="Link">
    					  [img]../img/<%=(contrappunti.Fields.Item([/img]" name="Testo" width="20" height="16" id="Testo">
    					  [img]../img/<%=(contrappunti.Fields.Item([/img]" name="Video" width="20" height="16" id="Video">
    					  [img]../img/<%=(contrappunti.Fields.Item([/img]" name="Audio" width="20" height="16" id="Audio">
    					  [img]../img/<%=(contrappunti.Fields.Item([/img]" name="Immagine" width="20" height="16" id="Immagine">
    					  </td>
                        </tr>
                      </table></td>
                  </tr>
                  <tr> 
                    <td bordercolor="#A6C030"><table width="652" border="0" align="center" cellpadding="1" cellspacing="0">
                        <tr> 
                          <td valign="top"><table width="575" height="70" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td valign="top"><%=(contrappunti.Fields.Item("sottotitolo").Value)%></td>
      </tr>
      <tr>
        <td height="10">">Dettagli ></td>
      </tr>
    </table></td>
                          <td width="72"><div align="center">[img]<%=(contrappunti.Fields.Item([/img]" width="70" height="70"></div></td>
                        </tr>
                      </table></td>
                  </tr>
                </table></td>
            </tr>
            <% 
      Repeat1__index=Repeat1__index+1
      Repeat1__numRows=Repeat1__numRows-1
      contrappunti.MoveNext()
    Wend
    %>
          </table>
          
           
          
          <p align="center"></p>
          
          
          
          <% If contrappunti.EOF And contrappunti.BOF Then %>
          </MM:DECORATION></MM_HIDDENREGION><MM_HIDDENREGION><MM:DECORATION OUTLINE="Show%20If..." OUTLINEID=2> 
          <p align="center"><font color="#99CC33" size="2">Spiacente ma la 
            ricerca non ha prodotto risultati</font></p>
           <% End If ' end contrappunti.EOF And contrappunti.BOF %>
          [/b] </td>
      </tr>
    </table>
    </body>
    </html>
    <%
    contrappunti.Close()
    Set contrappunti = Nothing
    %>

  7. #7
    contrappunti__MMColParam = Request.Form("ricerca")
    se contrappunti... è = al request.form devi sostituire su contrapp...

    contrappunti__MMColParam = replace(contrappunti__MMColParam," ","%")

  8. #8

    grazie Jacqui per le spiegazioni adesso funziona ma..

    ti spiego
    la sostituzione con % serve per far in modo che quando l'utente scrive nel form acer travelmate se ci sono parole in mezzo nei record del db mi trova comunque i record
    pero nel momento in cui uno scrive travel e acer non mi trova niente

    ho notato che se nell' URL metto & tra travel&acer me lo trova lo stesso
    es. result.asp?ricerca=travel&acer

    ho provato a sostiture nel
    contrappunti__MMColParam = replace(contrappunti__MMColParam," ","%")
    il carattere % con & ma non fuziona hai idee a riguardo



    scusa ma sono una novellina

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.