Avatar billede sylvesternielsen Nybegynder
05. marts 2002 - 11:01 Der er 4 kommentarer og
1 løsning

ændre kode...

Jeg har en text editor her....
Kan jeg få den til at smide indholdet videre i stedet for at gemme det?
F.eks. til admin.php
-------------------------------------------------------
<%@ Language = JavaScript %>
<html>

<head>
<title>Text editor v. 1.0</title>

<%if (Request.Querystring("action") == "save") {

tekst = Request.Form("teksten");

    var fso = new ActiveXObject("Scripting.FileSystemObject");

filplacering = Server.mapPath("/")

var a = fso.CreateTextFile(filplacering+"\\editor\\test.htm", true);
a.WriteLine(""+tekst);



Response.Redirect("default.asp")
Response.End()
}

%>


<html>

<head>
<title>Gemmer</title>
</head>



<head>
<style type="text/css">
TABLE#tblCoolbar
    {
    background-color:threedface; padding:1px; color:menutext;
    border-width:1px; border-style:solid;
    border-color:threedhighlight threedshadow threedshadow threedhighlight;
    }
.cbtn
    {
    height:18;
    BORDER-LEFT: threedface 1px solid;
    BORDER-RIGHT: threedface 1px solid;
    BORDER-TOP: threedface 1px solid;
    BORDER-BOTTOM: threedface 1px solid;
    }
.txtbtn {font-family:tahoma; font-size:70%; color:menutext;}
.progress{TEXT-DECORATION: none;FONT-SIZE: 12px;FONT-FAMILY: Arial Narrow;color=red}
TABLE
{
    FONT-WEIGHT: normal;
    FONT-SIZE: 12px;
    COLOR: black;
    LINE-HEIGHT: 120%;
    FONT-FAMILY: Verdana,Arial,sans-serif;
    TEXT-DECORATION: none
}
INPUT
{
    FONT-WEIGHT: normal;
    FONT-SIZE: 9px;
    COLOR: black;
    LINE-HEIGHT: 120%;
    FONT-FAMILY: Verdana,Arial,sans-serif;
    TEXT-DECORATION: none;
    style: "HEIGHT: 18px;
    WIDTH: 150px"
}
</style>

<script LANGUAGE="JavaScript">
function button_over(eButton)
    {
    eButton.style.backgroundColor = "#B5BDD6";
    eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
    }
function button_out(eButton)
    {
    eButton.style.backgroundColor = "threedface";
    eButton.style.borderColor = "threedface";
    }
function button_down(eButton)
    {
    eButton.style.backgroundColor = "#8494B5";
    eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
    }
function button_up(eButton)
    {
    eButton.style.backgroundColor = "#B5BDD6";
    eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
    eButton = null;
    }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

var isHTMLMode=false

function document.onreadystatechange()
    {
    try
        {
          idContent.document.designMode="On";
          }
      catch(e)
          {
          return;
          }
    }
function cmdExec(cmd,opt)
    {
      if (isHTMLMode){alert("Please uncheck 'Edit HTML'");return;}
      idContent.document.execCommand(cmd,"",opt);idContent.focus();
    }
function setMode(bMode)
    {
    var sTmp;
      isHTMLMode = bMode;
      if(isHTMLMode)
          {
          sTmp=idContent.document.body.innerHTML;
          idContent.document.body.innerText=sTmp;
          }
      else
          {
          sTmp=idContent.document.body.innerText;
          idContent.document.body.innerHTML=sTmp;
          }
      idContent.focus();
    }
function createLink()
    {
    if (isHTMLMode){alert("Please uncheck 'Edit HTML'");return;}
    cmdExec("CreateLink");
    }
function insertImage()
    {
    {
    var arr = showModalDialog("colorselector.htm","","font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:34em" );
    if (arr != null) cmdExec("ForeColor",arr);   
    }
    //if (isHTMLMode){alert("Please uncheck 'Edit HTML'");return;}
    //var sImgSrc=prompt("Insert Image File (You can use your local image file) : ", "http://www.aspalliance.com/Yusuf/Article10/sample.jpg");
    //if(sImgSrc!=null) cmdExec("InsertImage",sImgSrc);
    }
function Save()
    {
    if (isHTMLMode){alert("Please uncheck 'Edit HTML'");return;}
      var sImgTag = idContent.document.body.all.tags("IMG");
      var oImg;
      for (var i = sImgTag.length - 1; i >= 0; i--)
        {
        oImg = sImgTag[i];
        //alert("Add your code to Upload local image file here. Image Inserted : " + oImg.src );
          }
      //alert("Add your code to Save Document here");
      //alert("Your Document : " + idContent.document.body.innerHTML);
      SaveProcess(idContent.document.body.innerHTML); //##################
    }
function foreColor()
    {
    var arr = showModalDialog("colorselector.htm","","font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:34em" );
    if (arr != null) cmdExec("ForeColor",arr);   
    }
</script>

Retter tekst for <%=Request.Querystring("doc")%> for <%=Request.Querystring("lang")%>

<table id="tblCoolbar" width="542" cellpadding="0" cellspacing="0" align="center">
<tr valign="center">

    <td colspan="15">
        <select onchange="cmdExec('formatBlock',this[this.selectedIndex].value);this.selectedIndex=0" id="select1" name="select1">
            <option selected>Style</option>
            <option value="Normal">Normal</option>
            <option value="Heading 1">Heading 1</option>
            <option value="Heading 2">Heading 2</option>
            <option value="Heading 3">Heading 3</option>
            <option value="Heading 4">Heading 4</option>
            <option value="Heading 5">Heading 5</option>
            <option value="Address">Address</option>
            <option value="Formatted">Formatted</option>
            <option value="Definition Term">Definition Term</option>
        </select>
        <select onchange="cmdExec('fontname',this[this.selectedIndex].value);" id="select2" name="select2">
            <option selected>Font</option>
            <option value="Arial">Arial</option>
            <option value="Arial Black">Arial Black</option>
            <option value="Arial Narrow">Arial Narrow</option>
            <option value="Comic Sans MS">Comic Sans MS</option>
            <option value="Courier New">Courier New</option>
            <option value="System">System</option>
            <option value="Tahoma">Tahoma</option>
            <option value="Times New Roman">Times New Roman</option>
            <option value="Verdana">Verdana</option>
            <option value="Wingdings">Wingdings</option>
        </select>
        <select onchange="cmdExec('fontsize',this[this.selectedIndex].value);" id="select3" name="select3">
            <option selected>Size</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="10">10</option>
            <option value="12">12</option>
            <option value="14">14</option>
        </select>
       
    </td>
   
</tr>
<tr>

    <td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('cut')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Cut.gif" alt="Cut" WIDTH="23" HEIGHT="22">
    </div></td>
   
    <td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('copy')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Copy.gif" alt="Copy" WIDTH="23" HEIGHT="22">
    </div></td>   
   
    <td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('paste')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Paste.gif" alt="Paste" WIDTH="23" HEIGHT="22">
    </div></td>   
   
    <td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('bold')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Bold.gif" alt="Bold" WIDTH="23" HEIGHT="22">
    </div></td>
   
    <td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('italic')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Italic.gif" alt="Italic" WIDTH="23" HEIGHT="22">
    </div></td>   
   
    <td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('underline')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Under.gif" alt="Underline" WIDTH="23" HEIGHT="22">
    </div></td>       
       
    <td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('justifyleft')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Left.gif" alt="Justify Left" WIDTH="23" HEIGHT="22">
    </div></td>
   
    <td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('justifycenter')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Center.gif" alt="Center" WIDTH="23" HEIGHT="22">
    </div></td>   
   
    <td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('justifyright')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="1" vspace="1" align="absMiddle" src="gfx/editor/Right.gif" alt="Justify Right" WIDTH="23" HEIGHT="22">
    </div></td>       
   
    <td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('insertorderedlist')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="2" vspace="1" align="absMiddle" src="gfx/editor/numlist.GIF" alt="Ordered List" WIDTH="23" HEIGHT="22">
    </div></td>   

    <td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('insertunorderedlist')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="2" vspace="1" align="absMiddle" src="gfx/editor/bullist.GIF" alt="Unordered List" WIDTH="23" HEIGHT="22">
    </div></td>
       
    <td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('outdent')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="2" vspace="1" align="absMiddle" src="gfx/editor/deindent.gif" alt="Decrease Indent" WIDTH="23" HEIGHT="22">
    </div></td>   
   
    <td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('indent')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="2" vspace="1" align="absMiddle" src="gfx/editor/inindent.gif" alt="Increase Indent" WIDTH="23" HEIGHT="22">
    </div></td>           
   
    <td><div class="cbtn" onmousedown="button_down(this);" onClick="foreColor()" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="2" vspace="1" align="absMiddle" src="gfx/editor/fgcolor.gif" alt="Forecolor" WIDTH="23" HEIGHT="22">
    </div></td>           

    <td><div class="cbtn" onmousedown="button_down(this);" onClick="cmdExec('createLink')" onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="2" vspace="1" align="absMiddle" src="gfx/editor/Link.gif" alt="Link" WIDTH="23" HEIGHT="22">
    </div></td>   
   
    <td><div class="cbtn" onmousedown="button_down(this);"  onmouseover="button_over(this);" onmouseout="button_out(this);" onmouseup="button_up(this);">
    <img hspace="2" vspace="1" align="absMiddle" src="gfx/editor/Image.gif" alt="Disabled / slået fra!" WIDTH="23" HEIGHT="22">
    </div></td>
    <form method="POST" action="default.asp?action=save" name="saveresult" onClick="SaveProcess();">

    <td width="200"><input type="hidden" name="teksten" value=""><input type="submit" value="Gem" name="save">
</td>    </form>
   
</tr>
</table>

<table width="542" cellpadding="0" cellspacing="0" align="center">
<tr><td>

<iframe width="542" src="test.htm" id="idContent" height="350" align="center"></iframe>

</td></tr></table>

<script language="javascript" defer>
var WSDLURL = "Article12/edit.sdl";
var isFinish;
function initSVC()
    {
    service.use(WSDLURL, "FriendlyName");
    }
function SaveProcess(sText)
    {
    isFinish=false;

document.saveresult.teksten.value = idContent.document.body.innerHTML;

    }   
function checkReadyState()
    {
    if(isFinish==false){AnimateWindowStatus();window.setTimeout("checkReadyState()", 50);}
    }
function CallBackFunction(result)
    {
    isFinish=true;
    idProgress.innerText = " ";
   
    if(result.error) 
        {   
        var xfaultcode  = result.errorDetail.code;
        var xfaultstring = result.errorDetail.string;   
        var xfaultsoap  = result.errorDetail.raw;
        alert("Errors xfaultcode->" + xfaultcode + " xfaultstring->" + xfaultstring + " xfaultsoap->" + xfaultsoap);
        }
    else 
        {
        var xmlResult = result.raw.xml;
        //textarea1.value  = result.raw.xml;
        if (xmlResult != "" && xmlResult != null)
            {
            alert(result.raw.selectSingleNode("//result").text);
            }
        }
    }   
</script>
------------------------------------------------------
Avatar billede Søren Bech Morsing Praktikant
05. marts 2002 - 14:07 #1
du kan bare søge på "<form" og ændre action til admin.php

der kan du så request formfeltet teksten
Avatar billede sylvesternielsen Nybegynder
10. marts 2002 - 17:47 #2
dette her er hvad der sker når du trykker på den der form.
---------------------------------------------------
<%if (Request.Querystring("action") == "save") {

tekst = Request.Form("teksten");

    var fso = new ActiveXObject("Scripting.FileSystemObject");

filplacering = Server.mapPath("/")

var a = fso.CreateTextFile(filplacering+"\\editor\\test.htm", true);
a.WriteLine(""+tekst);



Response.Redirect("default.asp")
Response.End()
}
----------------------------------------------------
Så vidt jeg kan se kan det ikke bruges til at sende en forspørgsel til PHP....
Avatar billede Søren Bech Morsing Praktikant
10. marts 2002 - 18:15 #3
ja! og du skal nede i <form action sætte den til at sende det til din admin.php side i stedet.

På den kan du så requeste form feltet, som indeholder al teksten - det skal man kunne i PHP også.
Avatar billede sylvesternielsen Nybegynder
11. marts 2002 - 08:00 #4
ok så....
--------------------------------------------------------------------------------------
<form method="POST" action="default.asp?action=save" name="saveresult" onClick="SaveProcess();">

    <td width="200"><input type="hidden" name="teksten" value=""><input type="submit" value="Gem" name="save">
-----------------------------------------------------------------------------------
skal bare hedde:
-----------------------------------------------------------------------------------
<form method="POST" action="<? echo "PHP_SELF"; ?>" name="saveresult">
<td width="200"><input type="hidden" name="teksten" value="">
<input type="submit" value="Gem" name="save">

og så skulle alle værdier ligge i variablen $teksten eller hvad?
Avatar billede sylvesternielsen Nybegynder
29. august 2002 - 10:45 #5
lukker
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester