Avatar billede ofirpeter Nybegynder
14. marts 2004 - 00:57 Der er 9 kommentarer og
2 løsninger

Find variabel for tekst felt.

Jeg sidder og leger lidt med koden fra legestue's html-editor (http://www.eksperten.dk/spm/354198)

Hvis i prøver den (http://www.larsolesen.dk/htmleditor/editor.php) kan i se at når man trykker på submit kommer skriver den html'en ud.
Når jeg bare har lånt koden for hans side, får jeg selvfølgelig ikke php'en med. Og nu til mit spørgsmål.

Jeg skal skal have fanget html'en i en variabel, men kan ikke gennemskue hvilket tekstfelt det ligge i. Synes snart jeg har prøvet det meste :) Nogen der er skarpere end mig?

Peter
Avatar billede enux Nybegynder
14. marts 2004 - 01:07 #1
Prøv med

$newsPost

Men hvorfor ikke bare bruge SPAW?
Gratis, nem og meget bedre :)

http://www.solmetra.com/en/disp.php/en_products/en_spaw/en_spaw_about

God fornøjelse
Med venlig hilsen
Daniel Bahl
Enux Hosting
www.enux.dk
Avatar billede dennismp Nybegynder
14. marts 2004 - 01:07 #2
Du kan vel bare lave en print_r($_POST) (eller $_GET) og se hvilken variabel din tekst ligger i.
Avatar billede topsite Nybegynder
14. marts 2004 - 01:09 #3
dennismp, også en mulighed! :)

Men jeg holder stadig på: Brug Spaw! ;)
Avatar billede enux Nybegynder
14. marts 2004 - 01:10 #4
hæhæ flere Spaw brugere ;)

Genialt system
Avatar billede ofirpeter Nybegynder
14. marts 2004 - 01:26 #5
På trods af de mange opfordinger til at bruge spaw, forsætter jeg lidt endnu med den lille. Når jeg skriver echo print_r($_POST)
Skriver den bare:

Array ( ) 1

Og nu bliver jeg først forviret :)
Avatar billede enux Nybegynder
14. marts 2004 - 01:32 #6
Arr hvis du så gerne vil bruge den ;) så her da:

http://www.devarticles.com/c/a/ASP/Building-a-WYSIWYG-HTML-Editor-Part-2/2/

hæhæ
Næste side i bunden og læs :)
Avatar billede enux Nybegynder
14. marts 2004 - 01:33 #7
ups det var asp versionen, jeg roder lidt i mine bogmærker to sek
Avatar billede enux Nybegynder
14. marts 2004 - 01:34 #8
$html
Avatar billede ofirpeter Nybegynder
14. marts 2004 - 01:51 #9
$html ?

<html>
<head>
<title> Browser Based HTML Editor </title>
<script type="text/javascript">

  var viewMode = 1; // WYSIWYG

  function Init()
  {
    iView.document.designMode = 'On';
  }
 
  function selOn(ctrl)
  {
    ctrl.style.borderColor = '#000000';
    ctrl.style.backgroundColor = '#B5BED6';
    ctrl.style.cursor = 'hand';   
  }
 
  function selOff(ctrl)
  {
    ctrl.style.borderColor = '#D6D3CE'; 
    ctrl.style.backgroundColor = '#D6D3CE';
  }
 
  function selDown(ctrl)
  {
    ctrl.style.backgroundColor = '#8492B5';
  }
 
  function selUp(ctrl)
  {
    ctrl.style.backgroundColor = '#B5BED6';
  }
   
  function doBold()
  {
    iView.document.execCommand('bold', false, null);
  }

  function doItalic()
  {
    iView.document.execCommand('italic', false, null);
  }

  function doUnderline()
  {
    iView.document.execCommand('underline', false, null);
  }
 
  function doLeft()
  {
    iView.document.execCommand('justifyleft', false, null);
  }

  function doCenter()
  {
    iView.document.execCommand('justifycenter', false, null);
  }

  function doRight()
  {
    iView.document.execCommand('justifyright', false, null);
  }

  function doOrdList()
  {
    iView.document.execCommand('insertorderedlist', false, null);
  }

  function doBulList()
  {
    iView.document.execCommand('insertunorderedlist', false, null);
  }
 
  function doForeCol()
  {
    var fCol = prompt('Enter foreground color', '');
   
    if(fCol != null)
      iView.document.execCommand('forecolor', false, fCol);
  }

  function doBackCol()
  {
    var bCol = prompt('Enter background color', '');
   
    if(bCol != null)
      iView.document.execCommand('backcolor', false, bCol);
  }

  function doLink()
  {
    iView.document.execCommand('createlink');
  }
 
  function doImage()
  {
    var imgSrc = prompt('Enter image location', '');
   
    if(imgSrc != null)   
    iView.document.execCommand('insertimage', false, imgSrc);
  }
 
  function doRule()
  {
    iView.document.execCommand('inserthorizontalrule', false, null);
  }
 
  function doFont(fName)
  {
    if(fName != '')
      iView.document.execCommand('fontname', false, fName);
  }
 
  function doSize(fSize)
  {
    if(fSize != '')
      iView.document.execCommand('fontsize', false, fSize);
  }
 
  function doHead(hType)
  {
    if(hType != '')
    {
      iView.document.execCommand('formatblock', false, hType); 
      doFont(selFont.options[selFont.selectedIndex].value);
    }
  }
 
  function doToggleView()
  { 
    if(viewMode == 1)
    {
      iHTML = iView.document.body.innerHTML;
      iView.document.body.innerText = iHTML;
     
      // Hide all controls
      tblCtrls.style.display = 'none';
      selFont.style.display = 'none';
      selSize.style.display = 'none';
      selHeading.style.display = 'none';
      iView.focus();
     
      viewMode = 2; // Code
    }
    else
    {
      iText = iView.document.body.innerText;
      iView.document.body.innerHTML = iText;
     
      // Show all controls
      tblCtrls.style.display = 'inline';
      selFont.style.display = 'inline';
      selSize.style.display = 'inline';
      selHeading.style.display = 'inline';
      iView.focus();
     
      viewMode = 1; // WYSIWYG
    }
  }

function ProcessNews() {
// Assign the HTML code to a hidden form variable
var htmlCode = iView.document.body.innerHTML;
document.frmNews.newsPost.value = htmlCode;

// Make sure that all fields are completed
//if(document.frmNews.author.selectedIndex == 0)
//{
//alert('Please select an author for this news post.');
//document.frmNews.author.focus(); return false;
//}
//if(document.frmNews.title.value == '')
//{
//alert('This news post must contain a title.');
//document.frmNews.title.focus(); return false;
//}
//if(document.frmNews.topics.selectedIndex == -1)
//{
//alert('Please select a topic for this news post.');
//document.frmNews.topics.focus();
//return false;
//}
if(document.frmNews.newsPost.value == '')
{
alert('Please enter some content for this news post.');
iView.focus();
return false;
}
return true;
}



</script>
<style>

  .butClass
  {   
    border: 1px solid;
    border-color: #D6D3CE;
  }
 
  .tdClass
  {
    padding-left: 3px;
    padding-top:3px;
  }

</style>

<body onLoad="Init()">

    <table id="tblCtrls" width="415px" height="30px" border="0" cellspacing="0" cellpadding="0" bgcolor="#D6D3CE">   
    <tr>
        <td class="tdClass">
            <img alt="Bold" class="butClass" src="bold.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doBold()">
            <img alt="Italic" class="butClass" src="italic.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doItalic()">
            <img alt="Underline" class="butClass" src="underline.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doUnderline()">
           
            <img alt="Left" class="butClass" src="left.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doLeft()">
            <img alt="Center" class="butClass" src="center.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doCenter()">
            <img alt="Right" class="butClass" src="right.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doRight()">
                       
            <img alt="Ordered List" class="butClass" src="ordlist.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doOrdList()">
            <img alt="Bulleted List" class="butClass" src="bullist.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doBulList()">
           
<!--            <img alt="Text Color" class="butClass" src="forecol.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doForeCol()"> -->
<!--            <img alt="Background Color" class="butClass" src="bgcol.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doBackCol()"> -->
           
            <img alt="Hyperlink" class="butClass" src="link.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doLink()">
            <img alt="Image" class="butClass" src="image.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doImage()">
            <img alt="Horizontal Rule" class="butClass" src="rule.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doRule()">
           
        </td>
    </tr>
    </table>

    <table width="415px" height="30px" border="0" cellspacing="0" cellpadding="0" bgcolor="#D6D3CE">   
    <tr>
        <td class="tdClass" colspan="1" width="80%">
    <!--      <select name="selFont" onChange="doFont(this.options[this.selectedIndex].value)">
            <option value="">-- Font --</option>
            <option value="Arial">Arial</option>
            <option value="Courier">Courier</option>
            <option value="Sans Serif">Sans Serif</option>
            <option value="Tahoma">Tahoma</option>
            <option value="Verdana">Verdana</option>
            <option value="Wingdings">Wingdings</option>
          </select> -->
<!--          <select name="selSize" onChange="doSize(this.options[this.selectedIndex].value)">
            <option value="">-- Size --</option>
            <option value="1">Very Small</option>
            <option value="2">Small</option>
            <option value="3">Medium</option>
            <option value="4">Large</option>
            <option value="5">Larger</option>
            <option value="6">Very Large</option>
          </select>-->
<select name="selHeading" onChange="doHead(this.options[this.selectedIndex].value)">
<option value="">-- Heading --</option>
<option value="<h1>">h1</option>
<option value="<h2>">h2</option>
<option value="<h3>">h3</option>
<option value="<h4>">h4</option>
<option value="<h5>">h5</option>
<option value="<h6>">h6</option>
</select>


        </td>
        <td class="tdClass" colspan="1" width="20%" align="right">
          <img alt="Toggle Mode" class="butClass" src="mode.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doToggleView()">
          &nbsp;&nbsp;&nbsp;
        </td>
    </tr>
    </table>
    <iframe id="iView" style="width: 415px; height:205px"></iframe>
   
<form onSubmit="return ProcessNews()" name="frmNews" action="editor.php" method="post">
<input type="hidden" name="action" value="addNews">
<input type="hidden" name="newsPost" value="">
  <input type="submit" name="Submit" value="Submit">
</form>

<?
echo "$html";
?>
<p>&nbsp;</p>
</body>
</html>
Avatar billede enux Nybegynder
14. marts 2004 - 01:54 #10
<?
echo "$htmlCode $newsPost $iView $newsPost $html";
?>

Virker noget af det her ?
Avatar billede ofirpeter Nybegynder
14. marts 2004 - 11:48 #11
Jep! $newsPost var den rigtige! (Ved ikke hvad jeg gjorde forkert sidste gang jkeg prøvede den) Men hvertfald Tak.
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



IT-JOB