Vorschau von Formularfeld

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Vorschau von Formularfeld

    Hi,

    bin grad dabei für mein Gästebuch eine Erweiterung zu coden:
    Eine Vorschau in einem neuen Fenster des Eintrages

    Also ich hab das ganze auch schon hinbekommen mit Javascript:


    PHP-Code:
    <hmtl>
    <
    head>
    <
    script type="text/javascript">
    function 
    vorschau()
    {
    fenster window.open("","Fenster");
    fenster.document.open();
    fenster.document.writeln("<html><body>");
    fenster.document.writeln(document.Formular.Textfeld.value);
    fenster.document.writeln("</html></body>");
    fenster.document.close();
    }
    </
    script>
    </
    head>

    <
    body>

    <
    form name="Formular">
    <
    textarea name="Textfeld" rows="5" cols="20"></textarea><br>
    <
    input type="submit" value="vorschau" onclick="java script:vorschau();return false;">
    </
    form>

    </
    body>
    </
    html
    allerdings ist hierbei ja die Formatierung endkacke da er zB keine Zeilenumbrüche(<br>) interpretiert.

    mein quellcode:
    eingabe.php
    PHP-Code:
    <hmtl>
    <head>
    <script type="text/javascript">
    function open_new_window()

    window.open('vorschau.php','eintrag','resizeable=no,width=520,height=500,toolbar=no,scrollbars=no') 

    </script>
    </head>

    <body>

    <form name="submit" action="<?php echo $PHP_SELF?>" method="Post">
    <textarea name="eintrag" rows="5" cols="20"><?php echo $eintrag?></textarea><br>
    <input type="submit" value="Vorschau" onclick="open_new_window()">
    </form>

    </body>
    </html>
    vorschau.php ( wird aufgepoppt)
    PHP-Code:
    <html>
    <Title>Vorschau</Title>
    <body>
    <?php

    $uebergabe 
    htmlentities($eintrag)

    ?>

    <div align="Center">
      <table border="1" width="505">
        <tr>
          <td width="505" ><?php echo "$uebergabe<br>\n"?></td>
        </tr>
      </table>
    </div>

    </body>
    </html>
    also wie kann ich das realisieren?! besser mit Javascript das heisst kann man da noch was bei der Formatierung machen !?

  • #2
    Re: Vorschau von Formularfeld

    Original geschrieben von tomtherock
    PHP-Code:
    <html>
    <Title>Vorschau</Title>
    <body>
    <?php

    $uebergabe 
    htmlentities($eintrag)

    ?>

    <div align="Center">
      <table border="1" width="505">
        <tr>
          <td width="505" ><?php echo nl2br($uebergabe)."<br>\n"?></td>
        </tr>
      </table>
    </div>

    </body>
    </html>
    Sollte so gehen.
    *winks*
    Gilbert
    ------------------------------------------------
    Hilfe für eine Vielzahl von Problemen!!!
    http://www.1st-rootserver.de/

    Kommentar


    • #3
      also das Problem is denke ich schon früher, weil er garkein Wert übergibt :-(
      vielleicht bei Form action="?"

      PHP-Code:
      <hmtl>
      <head>
      <script type="text/javascript">
      function open_new_window()

      window.open('vorschau.php','eintrag','resizeable=no,width=520,height=500,toolbar=no,scrollbars=no') 

      </script>
      </head>

      <body>

      <form name="submit" action="<?php echo $PHP_SELF?>" method="Post">
      <textarea name="eintrag" rows="5" cols="20"><?php echo $eintrag?></textarea><br>
      <input type="submit" value="Vorschau" onclick="open_new_window()">
      </form>

      </body>
      </html>

      Kommentar


      • #4
        Code:
        <hmtl>
        <head>
        <script type="text/javascript">
        function open_new_window()
        { 
        window.open('vorschau.php','eintrag','resizeable=no,width=520,height=500,toolbar=no,scrollbars=no') 
        } 
        </script>
        </head>
        
        <body>
        
        <form name="submit" method="Post">
        <textarea name="eintrag" rows="5" cols="20"><?php echo $eintrag; ?></textarea><br>
        <input type="submit" value="Vorschau"onclick="document.submit.action='<?php echo $PHP_SELF; ?>'; document.submit.target='_self'">
         <input type="submit" value="Eintragen" onclick="document.submit.action='vorschau.php'; document.submit.target='_blank'">
        </form>
        
        </body>
        </html>
        wenn ich jetzt nicht ganz falsch liege müsste er bei vorschau ein neues fenster öffnen und die daten an vorschau.php senden ..
        zum anzeigen gehst gleich vor wie sonst .. nur dass die daten nicht speicherst - is ja nur vorschau
        mfg,
        [color=#0080c0]Coragon[/color]

        Kommentar


        • #5
          ja ich weiss *G* mich nervt das tierisch weil ich ja schon viel schwierigeres gescriptet hab allerdings halt ned mit Javascript drin....

          hab das jetzt mal so geändert -->

          PHP-Code:
          <form name="submit" onclick="open_new_window()" method="Post">
          <textarea name="eintrag" rows="5" cols="20"><?php echo $eintrag?></textarea><br>
          <input type="submit" value="Vorschau" >
          </form>
          geht leider ned.....

          ps: Ja hast richtig verstanden mit dem neuen Fenster

          Kommentar


          • #6
            kannst auch mal so versuchen ..

            Code:
            <hmtl>
            <head>
            </head>
            
            <body>
            
            <form name="submit" method="post" onsubmit="return false">
            <textarea name="eintrag" rows="5" cols="20">test</textarea><br>
            <input type="button" value="Eintragen" onclick="document.submit.action=''; document.submit.target='_self'; document.submit.submit()">
             <input type="submit" value="Vorschau" onclick="document.submit.action='vorschau.php'; document.submit.target='_blank'; document.submit.submit()">
            </form>
            
            </body>
            </html>
            EDIT:
            hab die beschriftung der buttons verwechselt

            EDIT:
            nochmal edit: bei mir funzt das
            Zuletzt geändert von Coragon Rivito; 28.10.2002, 09:24.
            mfg,
            [color=#0080c0]Coragon[/color]

            Kommentar


            • #7
              jo also das hat geklappt Danke ;-).
              Werd es jetzt noch ein wenig optimieren allerdings kenn ich mich halt leider in javascript nicht so aus damit ich jetzt mal schnell so was hincoden kann wie du ;-).

              In HTML kann man doch auch bestimmen wie groß das zu öffnente Fenster sein soll oder?!

              Oder mach ich das gleich in vorschau.php(is glaub am einfachsten)?

              Kommentar


              • #8
                Code:
                <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
                <hmtl>
                <head>
                
                  <title>Gästebuch</title>
                
                  <script type="test/javascript"> <!--
                
                    function senden() {
                
                      document.gb.action='<?php echo $PHP_SELF; ?>';
                      document.gb.target='_self';
                
                      if (preview) preview.close();
                
                      document.gb.submit()
                
                    }
                
                    function vorschau() {
                
                      preview = window.open("about:blank", "preview", "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=320,height=275");
                
                      document.gb.action='vorschau.php';
                      document.gb.target='preview';
                
                      document.gb.submit()
                
                    }
                
                  //--> </script>
                
                </head>
                
                <body>
                
                <form name="gb" method="post" onsubmit="return false" action="about:blank">
                  <textarea name="eintrag" rows="5" cols="20"><?php echo $eintrag; ?></textarea><br>
                  <input type="button" value="Eintragen" onclick="senden()"> &nbsp; &nbsp; <input type="button" value="Vorschau" onclick="vorschau()">
                </form>
                
                </body>
                </html>
                so richtig kann ichs wohl doch nicht .. obiger code hat nen fehler und ich komm ned dahinter ..
                Zuletzt geändert von Coragon Rivito; 28.10.2002, 09:55.
                mfg,
                [color=#0080c0]Coragon[/color]

                Kommentar


                • #9
                  passt schon *g*....mir wollte das Heute Früh einfach nicht gelingen...
                  soweit hab ich schon einen Plan wie man mit den Variablen etc submit Feldern umgeht ;-)

                  mal schauen ob bei mir das klappt!?

                  EDIT:

                  TEst 123 ;-)

                  Kommentar


                  • #10
                    http://www.php-resource.de/forum/sho...threadid=10377

                    wer suchet .. *bg*
                    mfg,
                    [color=#0080c0]Coragon[/color]

                    Kommentar

                    Lädt...
                    X