Formular Vorschau mit PHP & Javascript

N

nytemare

Hallo,

ich habe ein HTML formular, zu dem ich über einen Button onclick eine Vorschau mit Javascript öffnen möchte.

Quelltext:

PHP:
<form name="membership" method="post">
  Ihr Name:<br /><input style="margin-top: 4px;" name="yourname" type="text" size="35" /><br /><br />
  <script type="text/javascript">
    function memberShip() {
      var thepreview = window.open('', 'antrag', 'top=0,left=0,width=400,height=500,scrollbars=1,toolbar=1,menubar=0,location=0,resizable=1,fullscreen=0');
      thepreview.document.open();
      thepreview.document.writeln('<html>');
      thepreview.document.writeln('  <head>');
      thepreview.document.writeln('    <title>Antrag auf F&ouml;rdermitgliedschaft bei artforum3 e.V.</title>');
      thepreview.document.writeln('  </head>');
      thepreview.document.writeln('  <body>');
      thepreview.document.writeln('    Name: <?php echo $yourname; ?>');
      thepreview.document.writeln('  </body>');
      thepreview.document.writeln('</html>');
      thepreview.document.close();
    }
  </script>
  <input type="button" value="Senden" onclick="memberShip();" />
</form>

Das Erzeugen des Popups inkl. HTML-Quelltext funktioniert, nur die Variable aus dem input-Feld wird nicht ausgegeben.

Kann mir jemand weiterhelfen? Tausend Dank im voraus.

Gruß, nytemare
 
Hi habs ma en bisschen moddeliert

PHP:
  <script type="text/javascript"> 
    function memberShip() { 
      var thepreview = window.open('', 'antrag',  'top=0,left=0,width=400,height=500,scrollbars=1,toolbar=1,menubar=0,location=0,resizable=1,fullscreen=0'); 
      thepreview.document.open(); 
      thepreview.document.writeln('<html>'); 
      thepreview.document.writeln('  <head>'); 
      thepreview.document.writeln('    <title>Antrag auf F&ouml;rdermitgliedschaft bei artforum3 e.V.</title>'); 
      thepreview.document.writeln('  </head>'); 
      thepreview.document.writeln('  <body>'); 
      thepreview.document.writeln('    Name: <?= $_POST['yourname']; ?>'); 
      thepreview.document.writeln('  </body>'); 
      thepreview.document.writeln('</html>'); 
      thepreview.document.close(); 
    } 
  </script> 
<form name="membership" action="<?=$PHP_SELF ?>" method="post" onSubmit="memberShip()"> 
  Ihr Name:<br><input style="margin-top: 4px;" name="yourname" type="text" size="35"><br><br> 

  <input type="submit" value="Senden"> 
</form>

so funktioniert es bei mir. Der hat bei dir den Namen nicht übernommen weil du das Formular nicht abgesendest hast!

GreetZ AcidOne
 
Ändere $yourname mal in $_POST['yourname'] und wenn es klappt und du wissen willst warum das funktioniert dann lies mal hier weiter:www.php.net/globals

Da habe ich mich gestern auch durchgekämpft udn btw. auch die Lösung für mein Problem gefunden :D

mfg

Patrick Hau
 
Zurück