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

    Testo a Capo da Database

    Ciao a tutti,
    Come mai pur inserendo un testo in un db correlato dal comando "a capo", in fase di visualizzazione non segue il comando...

    Mi spiego meglio...

    Io dal form inserisco il testo:

    Prova invio di un testo
    nel database tramite un form

    ma quando lo richiamo dal database mi scrive:

    Prova invio di un testo nel database tramite un form

    In poche parole non mi considera il comando di "a Capo" (invio)

    Come mai?

    Il codice del form dal quale inserisco il testo è:

    codice:
    <%
    // *** Edit Operations: declare variables
    
    // set the form action variable
    var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
    if (Request.QueryString) {
      MM_editAction += "?" + Request.QueryString;
    }
    
    // boolean to abort record edit
    var MM_abortEdit = false;
    
    // query string to execute
    var MM_editQuery = "";
    %>
    <%
    // *** Insert Record: set variables
    
    if (String(Request("MM_insert")) == "form1") {
    
      var MM_editConnection = MM_connessione_STRING;
      var MM_editTable  = "contenuto_pagine";
      var MM_editRedirectUrl = "";
      var MM_fieldsStr = "textarea|value";
      var MM_columnsStr = "Testo|',none,''";
    
      // create the MM_fields and MM_columns arrays
      var MM_fields = MM_fieldsStr.split("|");
      var MM_columns = MM_columnsStr.split("|");
      
      // set the form values
      for (var i=0; i+1 < MM_fields.length; i+=2) {
        MM_fields[i+1] = String(Request.Form(MM_fields[i]));
      }
    
      // append the query string to the redirect URL
      if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
        MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.QueryString;
      }
    }
    %>
    <%
    // *** Insert Record: construct a sql insert statement and execute it
    
    if (String(Request("MM_insert")) != "undefined") {
    
      // create the sql insert statement
      var MM_tableValues = "", MM_dbValues = "";
      for (var i=0; i+1 < MM_fields.length; i+=2) {
        var formVal = MM_fields[i+1];
        var MM_typesArray = MM_columns[i+1].split(",");
        var delim =    (MM_typesArray[0] != "none") ? MM_typesArray[0] : "";
        var altVal =   (MM_typesArray[1] != "none") ? MM_typesArray[1] : "";
        var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : "";
        if (formVal == "" || formVal == "undefined") {
          formVal = emptyVal;
        } else {
          if (altVal != "") {
            formVal = altVal;
          } else if (delim == "'") { // escape quotes
            formVal = "'" + formVal.replace(/'/g,"''") + "'";
          } else {
            formVal = delim + formVal + delim;
          }
        }
        MM_tableValues += ((i != 0) ? "," : "") + MM_columns[i];
        MM_dbValues += ((i != 0) ? "," : "") + formVal;
      }
      MM_editQuery = "insert into " + MM_editTable + " (" + MM_tableValues + ") values (" + MM_dbValues + ")";
    
      if (!MM_abortEdit) {
        // execute the insert
        var MM_editCmd = Server.CreateObject('ADODB.Command');
        MM_editCmd.ActiveConnection = MM_editConnection;
        MM_editCmd.CommandText = MM_editQuery;
        MM_editCmd.Execute();
        MM_editCmd.ActiveConnection.Close();
    
        if (MM_editRedirectUrl) {
          Response.Redirect(MM_editRedirectUrl);
        }
      }
    
    }
    %>
    <%
    var Testo = Server.CreateObject("ADODB.Recordset");
    Testo.ActiveConnection = MM_connessione_STRING;
    Testo.Source = "SELECT *  FROM contenuto_pagine";
    Testo.CursorType = 0;
    Testo.CursorLocation = 2;
    Testo.LockType = 1;
    Testo.Open();
    var Testo_numRows = 0;
    %>
    <html>
    <head>
    <title>Documento senza titolo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <form name="form1" method="POST" action="<%=MM_editAction%>">
      
      <textarea name="textarea"></textarea>
      <input type="submit" name="Submit" value="Invia">
      <input type="hidden" name="MM_insert" value="form1">
    </form>
    </body>
    </html>
    <%
    Testo.Close();
    %>
    E poi richiamo il testo con questo codice:

    codice:
    <%=(pagina.Fields.Item("Testo").Value)%>
    Dove sbaglio?
    Come devo fare?

    Grazie a tutti ciao
    La Gratitudine è la prima cosa nella vita...

    Grazie a tutti

  2. #2
    <%=Replace((pagina.Fields.Item("Testo").Value), chr(10), "
    ", 1, -1, 1)%>

  3. #3
    ho provato così, ma mi da lo stesso problema

    Come posso fare?
    La Gratitudine è la prima cosa nella vita...

    Grazie a tutti

  4. #4

    Chi mi aiuta..?

    Come posso fare per risolvere il problema...?

    Chi mi aiuta
    La Gratitudine è la prima cosa nella vita...

    Grazie a tutti

  5. #5
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    codice:
    <%=Replace((pagina.Fields.Item("Testo").Value), VbCrLf, "
    ")%>

    Roby

  6. #6
    grazie per l'aiuto, ma a me servirebbe in js...

    Come posso fare?
    La Gratitudine è la prima cosa nella vita...

    Grazie a tutti

  7. #7
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    E quando lo dici?
    JS lato server o lato client?

    Roby

  8. #8

    avevo gia detto...

    Ciao a tutti,
    Come mai pur inserendo un testo in un db correlato dal comando "a capo", in fase di visualizzazione non segue il comando...

    Mi spiego meglio...

    Io dal form inserisco il testo:

    Prova invio di un testo
    nel database tramite un form

    ma quando lo richiamo dal database mi scrive:

    Prova invio di un testo nel database tramite un form

    In poche parole non mi considera il comando di "a Capo" (invio)

    Come mai?

    Il codice del form dal quale inserisco il testo è:

    code:<%
    // *** Edit Operations: declare variables

    // set the form action variable
    var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
    if (Request.QueryString) {
    MM_editAction += "?" + Request.QueryString;
    }

    // boolean to abort record edit
    var MM_abortEdit = false;

    // query string to execute
    var MM_editQuery = "";
    %>
    <%
    // *** Insert Record: set variables

    if (String(Request("MM_insert")) == "form1") {

    var MM_editConnection = MM_connessione_STRING;
    var MM_editTable = "contenuto_pagine";
    var MM_editRedirectUrl = "";
    var MM_fieldsStr = "textarea|value";
    var MM_columnsStr = "Testo|',none,''";

    // create the MM_fields and MM_columns arrays
    var MM_fields = MM_fieldsStr.split("|");
    var MM_columns = MM_columnsStr.split("|");

    // set the form values
    for (var i=0; i+1 < MM_fields.length; i+=2) {
    MM_fields[i+1] = String(Request.Form(MM_fields[i]));
    }

    // append the query string to the redirect URL
    if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
    MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.QueryString;
    }
    }
    %>
    <%
    // *** Insert Record: construct a sql insert statement and execute it

    if (String(Request("MM_insert")) != "undefined") {

    // create the sql insert statement
    var MM_tableValues = "", MM_dbValues = "";
    for (var i=0; i+1 < MM_fields.length; i+=2) {
    var formVal = MM_fields[i+1];
    var MM_typesArray = MM_columns[i+1].split(",");
    var delim = (MM_typesArray[0] != "none") ? MM_typesArray[0] : "";
    var altVal = (MM_typesArray[1] != "none") ? MM_typesArray[1] : "";
    var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : "";
    if (formVal == "" || formVal == "undefined") {
    formVal = emptyVal;
    } else {
    if (altVal != "") {
    formVal = altVal;
    } else if (delim == "'") { // escape quotes
    formVal = "'" + formVal.replace(/'/g,"''") + "'";
    } else {
    formVal = delim + formVal + delim;
    }
    }
    MM_tableValues += ((i != 0) ? "," : "") + MM_columns[i];
    MM_dbValues += ((i != 0) ? "," : "") + formVal;
    }
    MM_editQuery = "insert into " + MM_editTable + " (" + MM_tableValues + ") values (" + MM_dbValues + ")";

    if (!MM_abortEdit) {
    // execute the insert
    var MM_editCmd = Server.CreateObject('ADODB.Command');
    MM_editCmd.ActiveConnection = MM_editConnection;
    MM_editCmd.CommandText = MM_editQuery;
    MM_editCmd.Execute();
    MM_editCmd.ActiveConnection.Close();

    if (MM_editRedirectUrl) {
    Response.Redirect(MM_editRedirectUrl);
    }
    }

    }
    %>
    <%
    var Testo = Server.CreateObject("ADODB.Recordset");
    Testo.ActiveConnection = MM_connessione_STRING;
    Testo.Source = "SELECT * FROM contenuto_pagine";
    Testo.CursorType = 0;
    Testo.CursorLocation = 2;
    Testo.LockType = 1;
    Testo.Open();
    var Testo_numRows = 0;
    %>
    <html>
    <head>
    <title>Documento senza titolo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <form name="form1" method="POST" action="<%=MM_editAction%>">

    <textarea name="textarea"></textarea>
    <input type="submit" name="Submit" value="Invia">
    <input type="hidden" name="MM_insert" value="form1">
    </form>
    </body>
    </html>
    <%
    Testo.Close();
    %>



    E poi richiamo il testo con questo codice:

    code:<%=(pagina.Fields.Item("Testo").Value)%>



    Dove sbaglio?
    Come devo fare?

    Grazie a tutti ciao

    avevo gia detto che serviva in js...

    Cmq, se puoi aiutarmi te ne sarò grato...

    grazie tante Roby
    La Gratitudine è la prima cosa nella vita...

    Grazie a tutti

  9. #9
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Cerca la sintassi della replace in Js.

    Roby

  10. #10

    Non ci riesco

    ho cercato "replace javascript" ma non mi estrapola nulla...
    come posso risolvere questo problemino con il replace...?

    chi mi da una mano?

    grazie a tutti ciao
    La Gratitudine è la prima cosa nella vita...

    Grazie a tutti

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.