samedi 4 septembre 2021

I want the submitted form's data to be displayed on to another window.(Using only window object in javascript)

I want the submitted form's data to be displayed on to another window.(Using only window object in javascript). This is the code i've tried so far. It opens a new window but doesn't seem to write anything, Iv'e even tried to use document.write with just simple text but that doesn't seem to work either. Iv'e also tried to run other example off of the internet and it seems to work fine so I think there's some fault in my code only.

 <!DOCTYPE html>
    <html>
    <head>
       <meta charset="utf-8">
       <title>Practical 16</title>
       <script language="javascript" type="text/javascript">
          function openWindow() {
             var nwin = window.open("","win","width=300,height=150");
             var name = document.forms["Registration"]["name"];
             var phone = document.forms["Registration"]["phone"];
             var email = document.forms["Registration"]["email"];
             var pos = document.forms["Registration"]["pos"];
             var address = document.forms["Registration"]["address"];
    
             nwin.document.write("Fullname"+name.value);
             nwin.document.write("<p> This is 'anotherWindow'. It is 300px wide and 150px tall new window! </p>");
          }
       </script>
    </head>
     
    <body>
       <div style="margin:0 400px;">
       <form name="resume" method="post" onsubmit="openWindow()">
          <table style="border-spacing: 20px;">
             
             <tr>
             
                <td>            
                   <b>Full Name:</b>
                </td>
             
                <td>
                   <input type="text" name="name" id="name"/>
                </td>
             
             </tr>
             
             <tr>
             
                <td>
                   <b>Email:</b>
                </td>
             
                <td>
                   <input type="text" name="email"/>
                </td>
             
             </tr>
             
             <tr>
             
                <td>
                   <b>Phone No:</b>
                </td>
             
                <td>
                   <input type="text"  name="phone"/>
                </td>
             
             </tr>
             
             <tr>
             
                <td>
                   <b>Address:</b>
                </td>
             
                <td>
                   <input type="text"  name="address"/>
                </td>
             
             </tr>
    
             <tr>
             
                <td>
                   <b>Position Applying For:</b>
                </td>
             
                <td>
                   <input type="text"  name="pos"/>
                </td>
             
             </tr>
    
             <tr>
             
                <td>
                   <b>Upload CV:</b>
                </td>
             
                <td>
                   <input type="file" id="myFile" name="filename">
                </td>
             
             </tr>
    
             <tr>
             
                <td colspan="2">
                   <input type="submit" value="Submit" name="submit"  style="width: 20em;  height: 2em; margin: 0 40px;"/>
                </td>
             
             </tr>
       </table>
    
       </form>
       </div>
    </body>
    </html>



Aucun commentaire:

Enregistrer un commentaire