Salve a tutti,
sto utilizzando un editor WYSIWYG cross browser, pubblicato
anche da voi all'indirizzo https://www.mrw.it/script/openwysiwyg_645.html
e ho un problema quando faccio la submit.
Mi spiego:
il form in questione contiene il campo textarea - con cui lavora l'editor - più altri campi.
Alla fine del form ho inserito l'istruzione <INPUT type="button" value="add" name="b1" onclick="Control()"> al posto della solita <INPUT type="submit" value="add" name="b1" >.
Questo per eseguire dei controlli javascript su altri campi del form.
Il problema però è che con il type=button quando nel file .asp successivo provo a stampare a video il contenuto della textarea non ci trovo niente, mentre gli altri campi del form sono valorizzati.
Diversamente quando uso il type submit il valore me lo stampa.
Ovviamente nella funzione javascript alla fine c'é l'istruzione "formname.submit"
Provo a postare il codice.
<%@LANGUAGE="VBSCRIPT"%>
<!--#INCLUDE VIRTUAL="/inc/config.asp"-->
<html>
<head>
<title>Editor</title>
<Script Language="Javascript">
function bisestile (year)
{
if ((year % 4) == 0)
{
return true
}
else
{
return false
}
}
function Controlla()
{
var Errore=0;
var giorno = srv.data.value.substring(0,2);
var mese = srv.data.value.substring(3,5);
var anno = srv.data.value.substring(6,10);
var sep1 = srv.data.value.substring(2, 3);
var sep2 = srv.data.value.substring(5,6);
var doc = srv.documento.value;
doc=doc.substr(doc.lastIndexOf(".")+1);
doc=doc.substr(doc.lastIndexOf(".")+1);
doc=doc.toUpperCase();
if (srv.titolo.value == "")
{
alert('Inserire il titolo della news');
Errore = 1;
}
else if (srv.data.value.length != 10)
{
alert('La data deve essere di 10 caratteri con il separatore /');
Errore = 1;
}
else if (srv.data.value.length != 10)
{
alert('La data deve essere di 10 caratteri con il separatore /');
Errore = 1;
}
else if ((giorno == 31)&& ((mese == 9) || (mese == 11) || (mese == 6) || (mese == 4)))
{
alert('Il mese selezionato non ha più di 30 giorni');
Errore = 1;
}
else if (giorno > 31)
{
alert('Non esistono mesi con più di 31 giorni');
Errore = 1;
}
else if (mese > 12)
{
alert('I mesi dell\'anno sono 12');
Errore = 1;
}
else if ((giorno > 29)&& ((mese == 2)))
{
alert('Il mese selezionato non ha più di 29 giorni');
Errore = 1;
}
else if ( (sep1)!= "/" || (sep2)!= "/" )
{
alert('Inserire il separatore "/" nella data');
Errore = 1;
}
else if ( (giorno > 28) && (mese == 2) && (!(bisestile(anno))) )
{
alert('L\'anno non è bisestile, febbraio ha solo 28 giorni');
Errore = 1;
}
else if ((srv.documento.value != "") && ( ! ( (doc == "DOC") || (doc == "XLS") || (doc == "CSV") || (doc == "TXT") || (doc == "PDF") || (doc == "PPT") ) ))
{
alert('Le estensioni consentite per il documento sono: DOC, XLS, CSV, TXT, PDF o PPT');
Errore = 1;
}
if (Errore == 0)
{
srv.submit();
}
}
</Script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- css per il sito -->
<LINK HREF="../css/style.css" TYPE="text/css" REL="stylesheet">
<link rel="stylesheet" href="../editor/docs/style.css" type="text/css">
<!--
Include i file javascript
-->
<%If request.QueryString("save") <> "yes" then %>
<script type="text/javascript" src="../editor/scripts/wysiwyg.js"></script>
<script type="text/javascript" src="../editor/scripts/wysiwyg-settings.js"></script>
<%end if %>
<!--
Inserisce l'editor nella textarea
-->
</head>
<body>
<%
If request.QueryString("save") = "yes" then
'Versione 2.1 Set Upload = Server.CreateObject("Persits.Upload.1")
Set Upload = Server.CreateObject("Persits.Upload")
'******************** Codice per la Progress Bar ********************
Upload.ProgressID=Request.QueryString("PID")
'******************** Fine codice per la Progress Bar ********************
Upload.OverwriteFiles=True
Upload.Save
For Each File in Upload.Files
NomefileOrigine=File.OriginalPath
NomefileUploadato=File.Path
NomeBreve=File.ExtractFileName
Dimensione=File.Size
estensione=GetFileExtension(NomefileOrigine)
if ucase(estensione)=".DOC" or ucase(estensione)=".XLS" or ucase(estensione)=".CSV" or ucase(estensione)=".TXT" or ucase(estensione)=".PDF" or ucase(estensione)=".PPT" then
percorso=root & ("\documenti\news\") & nomebreve
File.SaveAs(percorso)
call renamefileuploadato(percorso, nomebreve)
strdocumento="documenti/news/" & nomebreve
end if
Next
For Each Item in Upload.Form
if Item.Name = "titolo" then titolo = Item.Value
if Item.Name = "fonte" then fonte = Item.Value
if Item.Name = "data" then data = Item.Value
if Item.Name = "test1" then des = Item.Value
if Item.Name = "areaint" then areaint = Item.Value
if Item.Name = "newsletter" then newsletter = Item.Value
Next
'For Each Item in Upload.Form
'Response.Write Item.Value & "<BR>"
'Next
Response.Write titolo & "<BR>"
Response.Write fonte & "<BR>"
Response.Write data & "<BR>"
Response.Write des & "<BR>"
Response.Write areaint & "<BR>"
response.end
Else
%>
<!--
Inserisce l'editor nella textarea
-->
<script type="text/javascript">
WYSIWYG.attach('textarea1'); // default setup
</script>
<form action="default.asp?save=yes&titolo=<%=titolo%>&id=<%=id%>&<%=PID%>" enctype="multipart/form-data" method="post" id=form1 name="srv">
<div style="margin-left:10px ">Titolo:
<input type="text" maxlength=200 size=45 style="font-family:tahoma; font-size:11px; margin-left:62px " name="titolo" onblur="this.value=this.value.replace(/^\s*/,'')">
</div>
<div style="margin-left:10px ">Fonte:
<input type="text" maxlength=100 size=45 style="font-family:tahoma; font-size:11px; margin-left:60px " name="fonte" onblur="this.value=this.value.replace(/^\s*/,'')">
</div>
<!--<form name="exampleForm" action="default.asp?save=yes&<%=PID%>" enctype="multipart/form-data" method="post"><br>-->
<div style="margin-left:10px ">Descrizione:
<!-- Modifiche per inserimento Editor -->
<textarea id="textarea1" name="test1" style="width:560px;height:200px;"></textarea><br />
<!-- Fine modifiche per inserimento Editor -->
</div>
<div style="margin-left:10px ">Data:
<input type="text" maxlength=20 size=20 style="font-family:tahoma; font-size:11px; margin-left:65px " name="data" onblur="this.value=this.value.replace(/^\s*/,'')">
</div>
<div style="margin-left:10px ">Documento:
<input type="file" maxlength=50 size=45 style="font-family:tahoma; font-size:11px; margin-left:34px" name="documento">
</div>
<div style="margin-left:10px ">Area Intervento:
<select size=1 style="font-family:tahoma; font-size:11px; margin-left:10px " name="areaint">
<%
dim RSAreaIntervento
set RSAreaIntervento = Server.CreateObject("ADODB.RECORDSET")
RSAreaIntervento.ActiveConnection=Objconn
RSAreaIntervent
pen("Select * from T_AreeIntervento")
Response.Write("<option selected>Scegli un'area</option>")
while not RSAreaIntervento.EOF
Response.Write "<option value=" & trim(RSAreaIntervento(0)) & ">" & RSAreaIntervento(1) & "</option>" & vbcrlf
RSAreaIntervento.movenext
wend
RSAreaIntervento.close
set RSAreaIntervento=nothing
%>
</select>
<div style="margin-left:0px ">Newsletter:
<input type=checkbox style="font-family:tahoma; font-size:11px; margin-left:33px " name="newsletter">
</div>
<div style="margin-left:150px ">
<br style="line-height:5px ">
<INPUT type="button" value="aggiungi" name="b1" onclick="Controlla()"> <input type="Reset" Value="annulla" id=Reset1 name=Reset1>
</div>
<br>
</form>
<%
End If
%>
</body>
</html>
non so se qualcuno può darmi una mano, comunque ci provo.
Grazie comunque
sto utilizzando un editor WYSIWYG cross browser, pubblicato
anche da voi all'indirizzo https://www.mrw.it/script/openwysiwyg_645.html
e ho un problema quando faccio la submit.
Mi spiego:
il form in questione contiene il campo textarea - con cui lavora l'editor - più altri campi.
Alla fine del form ho inserito l'istruzione <INPUT type="button" value="add" name="b1" onclick="Control()"> al posto della solita <INPUT type="submit" value="add" name="b1" >.
Questo per eseguire dei controlli javascript su altri campi del form.
Il problema però è che con il type=button quando nel file .asp successivo provo a stampare a video il contenuto della textarea non ci trovo niente, mentre gli altri campi del form sono valorizzati.
Diversamente quando uso il type submit il valore me lo stampa.
Ovviamente nella funzione javascript alla fine c'é l'istruzione "formname.submit"
Provo a postare il codice.
<%@LANGUAGE="VBSCRIPT"%>
<!--#INCLUDE VIRTUAL="/inc/config.asp"-->
<html>
<head>
<title>Editor</title>
<Script Language="Javascript">
function bisestile (year)
{
if ((year % 4) == 0)
{
return true
}
else
{
return false
}
}
function Controlla()
{
var Errore=0;
var giorno = srv.data.value.substring(0,2);
var mese = srv.data.value.substring(3,5);
var anno = srv.data.value.substring(6,10);
var sep1 = srv.data.value.substring(2, 3);
var sep2 = srv.data.value.substring(5,6);
var doc = srv.documento.value;
doc=doc.substr(doc.lastIndexOf(".")+1);
doc=doc.substr(doc.lastIndexOf(".")+1);
doc=doc.toUpperCase();
if (srv.titolo.value == "")
{
alert('Inserire il titolo della news');
Errore = 1;
}
else if (srv.data.value.length != 10)
{
alert('La data deve essere di 10 caratteri con il separatore /');
Errore = 1;
}
else if (srv.data.value.length != 10)
{
alert('La data deve essere di 10 caratteri con il separatore /');
Errore = 1;
}
else if ((giorno == 31)&& ((mese == 9) || (mese == 11) || (mese == 6) || (mese == 4)))
{
alert('Il mese selezionato non ha più di 30 giorni');
Errore = 1;
}
else if (giorno > 31)
{
alert('Non esistono mesi con più di 31 giorni');
Errore = 1;
}
else if (mese > 12)
{
alert('I mesi dell\'anno sono 12');
Errore = 1;
}
else if ((giorno > 29)&& ((mese == 2)))
{
alert('Il mese selezionato non ha più di 29 giorni');
Errore = 1;
}
else if ( (sep1)!= "/" || (sep2)!= "/" )
{
alert('Inserire il separatore "/" nella data');
Errore = 1;
}
else if ( (giorno > 28) && (mese == 2) && (!(bisestile(anno))) )
{
alert('L\'anno non è bisestile, febbraio ha solo 28 giorni');
Errore = 1;
}
else if ((srv.documento.value != "") && ( ! ( (doc == "DOC") || (doc == "XLS") || (doc == "CSV") || (doc == "TXT") || (doc == "PDF") || (doc == "PPT") ) ))
{
alert('Le estensioni consentite per il documento sono: DOC, XLS, CSV, TXT, PDF o PPT');
Errore = 1;
}
if (Errore == 0)
{
srv.submit();
}
}
</Script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- css per il sito -->
<LINK HREF="../css/style.css" TYPE="text/css" REL="stylesheet">
<link rel="stylesheet" href="../editor/docs/style.css" type="text/css">
<!--
Include i file javascript
-->
<%If request.QueryString("save") <> "yes" then %>
<script type="text/javascript" src="../editor/scripts/wysiwyg.js"></script>
<script type="text/javascript" src="../editor/scripts/wysiwyg-settings.js"></script>
<%end if %>
<!--
Inserisce l'editor nella textarea
-->
</head>
<body>
<%
If request.QueryString("save") = "yes" then
'Versione 2.1 Set Upload = Server.CreateObject("Persits.Upload.1")
Set Upload = Server.CreateObject("Persits.Upload")
'******************** Codice per la Progress Bar ********************
Upload.ProgressID=Request.QueryString("PID")
'******************** Fine codice per la Progress Bar ********************
Upload.OverwriteFiles=True
Upload.Save
For Each File in Upload.Files
NomefileOrigine=File.OriginalPath
NomefileUploadato=File.Path
NomeBreve=File.ExtractFileName
Dimensione=File.Size
estensione=GetFileExtension(NomefileOrigine)
if ucase(estensione)=".DOC" or ucase(estensione)=".XLS" or ucase(estensione)=".CSV" or ucase(estensione)=".TXT" or ucase(estensione)=".PDF" or ucase(estensione)=".PPT" then
percorso=root & ("\documenti\news\") & nomebreve
File.SaveAs(percorso)
call renamefileuploadato(percorso, nomebreve)
strdocumento="documenti/news/" & nomebreve
end if
Next
For Each Item in Upload.Form
if Item.Name = "titolo" then titolo = Item.Value
if Item.Name = "fonte" then fonte = Item.Value
if Item.Name = "data" then data = Item.Value
if Item.Name = "test1" then des = Item.Value
if Item.Name = "areaint" then areaint = Item.Value
if Item.Name = "newsletter" then newsletter = Item.Value
Next
'For Each Item in Upload.Form
'Response.Write Item.Value & "<BR>"
'Next
Response.Write titolo & "<BR>"
Response.Write fonte & "<BR>"
Response.Write data & "<BR>"
Response.Write des & "<BR>"
Response.Write areaint & "<BR>"
response.end
Else
%>
<!--
Inserisce l'editor nella textarea
-->
<script type="text/javascript">
WYSIWYG.attach('textarea1'); // default setup
</script>
<form action="default.asp?save=yes&titolo=<%=titolo%>&id=<%=id%>&<%=PID%>" enctype="multipart/form-data" method="post" id=form1 name="srv">
<div style="margin-left:10px ">Titolo:
<input type="text" maxlength=200 size=45 style="font-family:tahoma; font-size:11px; margin-left:62px " name="titolo" onblur="this.value=this.value.replace(/^\s*/,'')">
</div>
<div style="margin-left:10px ">Fonte:
<input type="text" maxlength=100 size=45 style="font-family:tahoma; font-size:11px; margin-left:60px " name="fonte" onblur="this.value=this.value.replace(/^\s*/,'')">
</div>
<!--<form name="exampleForm" action="default.asp?save=yes&<%=PID%>" enctype="multipart/form-data" method="post"><br>-->
<div style="margin-left:10px ">Descrizione:
<!-- Modifiche per inserimento Editor -->
<textarea id="textarea1" name="test1" style="width:560px;height:200px;"></textarea><br />
<!-- Fine modifiche per inserimento Editor -->
</div>
<div style="margin-left:10px ">Data:
<input type="text" maxlength=20 size=20 style="font-family:tahoma; font-size:11px; margin-left:65px " name="data" onblur="this.value=this.value.replace(/^\s*/,'')">
</div>
<div style="margin-left:10px ">Documento:
<input type="file" maxlength=50 size=45 style="font-family:tahoma; font-size:11px; margin-left:34px" name="documento">
</div>
<div style="margin-left:10px ">Area Intervento:
<select size=1 style="font-family:tahoma; font-size:11px; margin-left:10px " name="areaint">
<%
dim RSAreaIntervento
set RSAreaIntervento = Server.CreateObject("ADODB.RECORDSET")
RSAreaIntervento.ActiveConnection=Objconn
RSAreaIntervent

Response.Write("<option selected>Scegli un'area</option>")
while not RSAreaIntervento.EOF
Response.Write "<option value=" & trim(RSAreaIntervento(0)) & ">" & RSAreaIntervento(1) & "</option>" & vbcrlf
RSAreaIntervento.movenext
wend
RSAreaIntervento.close
set RSAreaIntervento=nothing
%>
</select>
<div style="margin-left:0px ">Newsletter:
<input type=checkbox style="font-family:tahoma; font-size:11px; margin-left:33px " name="newsletter">
</div>
<div style="margin-left:150px ">
<br style="line-height:5px ">
<INPUT type="button" value="aggiungi" name="b1" onclick="Controlla()"> <input type="Reset" Value="annulla" id=Reset1 name=Reset1>
</div>
<br>
</form>
<%
End If
%>
</body>
</html>
non so se qualcuno può darmi una mano, comunque ci provo.
Grazie comunque