Distributing form elements among different web pages looks simple but fails to fix

This question is similar to my previous question, but not the same ... please check .... I use totaly 3 web pages; form elements are distributed between the two pages "eg1.html" and "eg2.html", but all form elements must be represented by "eg.php".

Here is the code for eg.php which accepts the form elements from both eg1.html and eg2.html: $size=$_POST["fontsize"]; $label=$_POST["label"]; $age=$_POST["age"]; $sex =$_POST["sex"]; code for eg1.html <html> <body> <form action="eg.php" method="post"> <input type="radio" name="fontsize" value="3"/> <a href="eg2.html">click here to select other options which includes age and sex</a> <input type="radio" name="label" value="stacks"/> <input type="submit" name = "down" value = "down"> </form> </body> Now What would be the code for eg2.html? just check out sample partial html code :but needs to be compleated.... <input type="radio" name="age" value="3"/> <input type="radio" name="sex" value="female"/> 

The code should work just like this: The first user will open eg1.php, he chooses only one option, which is "fontsize". Then he clicks on the link β€œeg2.html” to select two more options β€œage” and β€œsex” after selection ... he will redirect back to eg1.php, where he should select another parameter, which is the β€œlabel” ... then it will submit the form to eg.php. In which all the elements of the form will be stored, this is "fontization", "age" and "label" .....
I have seen many websites using this technique, please check cooltext.com, where the user will be able to click on the font image, which will redirect it to the font page after selecting one of the font images, which will be redirected to the main page, where he can select some other form elements or form elements and finally submit the form .... I also saw a lot of sites using this technique, I think it can be done using JQUERY / JavaScript, but not sure ..., please help get me to fix this guyz problem. ,,

+4
source share
1 answer

Using js, you can have the whole form on one page and divide it as shown

 <form action="eg.php" method="post"> <div class="step1"> <input type="radio" name="fontsize" value="3"/> <a href="#" id="step1_submit">click here to select other options which includes age and sex</a> <input type="radio" name="label" value="stacks"/> <input type="submit" name = "down" value = "down"> </div> <div class="step2"> <a href="#" id="step2_back">click here to go back to step1</a> <input type="radio" name="age" value="3"/> <input type="radio" name="sex" value="female"/> <input type="submit" value="Submit"/> </div> </form> 

JS:

 $('#step1_submit').click(function(){ $('#step1').hide(); $('#step2').show(); }); $('#step2_back').click(function(){ $('#step1').show(); $('#step2').hide(); }); 
+2
source

Source: https://habr.com/ru/post/1396411/


All Articles