javascript - Displaying a 'hidden' form once the first form is filled and submit button clicked -


I have two HTML forms where the second form 'display: none;' And so when I do not load the page (only the first form loads)

This idea once was filled in the form for the first time and its button is clicked, to display the second form The latter is not displayed, which is filled after the display and it has been deposited on a 'thank you page'

This is the first form, which is displayed when the page is loaded:

  & lt; Form id = "form1" & gt; ; & Lt; Table class = "tbl" & gt; & Lt; TR & gt; & Lt; TD & gt; Title * & lt; / Td> & Lt; / Tr & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Input type = "text" name = "title" category = "title" required & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; First Name * & lt; / Td> & Lt; / Tr & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Input type = "text" name = "fname" class = "fname" required & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Button ID = "BTN" onClick = "document.getElementById ('form2'). Style.display = '';" & Gt; & Lt; IMG src = "picture / next .png" /> & Lt; / Button & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Form & gt;  

And this is the second form, which has been successfully filled for the first time and clicked on the submit button (I have verified the first form with the 'required' attribute).

& lt; Form id = "form2" method = "post" action = "thankyou_page.php" & gt; & Lt; Table class = "tbl2" & gt; & Lt; TR & gt; & Lt; TD & gt; Email * & lt; / Td> & Lt; / Tr & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Input type = "text" name = "email" class = "email" required & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Telephone * & lt; / Td> & Lt; / Tr & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Input type = "text" name = "phone" class = "phone" required & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Button id = "btn1" & gt; & Lt; Img src = "images / get_decorating_quotes.png" /> & Lt; / Button & gt; & Lt; / Td> & Lt; / Tr & gt;

After that I have used an external CSS file for my style..How I have done for 'form2'

  # form2 { Display: none; }  

How long I get after loading my page is that once I press the button on the first form ('Form1'), then 'form 2 'If it is displayed then' Please fill this field. 'Verification message. My wish is first for Form 1 and after filling all the fields,' Form 2 '(for' BTN 'using the onclick function) Using, while still 'form1' contains the content of the form As I fill out and submit 'Form 2'.

Any help would be appreciated.

What you need to do, such verification function is called:

  & lt; Button ID = "BTN" onClick = "return validate ();" & Gt;  

Then you have some type of function near the function that you have decided that verification fails:

  verification of function () { Var isValid = true; Var form 1 = document. GetElementById ('form1'); If (form1.title.value == '') {isValid = false; } If (form1.fname.value == '') {isValid = false; } If (isValid) {document.getElementById ('form2'). Style.display = 'block'; return false; }}  


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -