jimfog Posted December 4, 2012 Share Posted December 4, 2012 (edited) I have a form in which some fields will be displayed only if the user chooses a specific optionfrom 2 radio buttons.These form fields are set to display="none" and I use javascript to make them visible. I have also made a function where it checks if the user has filled in the fields. And here comes the problem. The function checks all the fields, even of the ones that are set to display, none. That said,if the user fills in all the fields required for a specific option chosen(in which option the fields set to display none stay hidden from view), still, the function that checks if the fields are filled outputs false-so, modifications are required,what do you propose? here is the function and beneath it is the form: function filled_out($post){ $wasFilledOutCompletely = true; // test that each key has a non empty string value foreach ($post as $key => $value) { if ($value == '') { $wasFilledOutCompletely = false; } } return $wasFilledOutCompletely; } <form action="register_form.php" method="post"> <input name="username/e-mail" placeholder="Username/e-mail" type="text" size="40" /><br> <input type="radio" name="usertype" value="0"> End user<br> <input type="radio" name="usertype" value="1"> Business user<br> <select style="display:none;" name="usertype"> <option value="1">test1</option> <option value="2">test2</option> <option value="3">test3</option> <option value="4">test4</option> </select> <input style="display:none;" name="name" placeholder=Name" type="text" size="40" /><br> <input style="display:none;" name="lastname" placeholder="lastname"type="text" size="40" /><br> <input name="password" placeholder="Password"type="text" size="40" /><br> <input name="passwordretyped" placeholder="Password...again" type="text" size="40" /><br> <fieldset class="formset"><input name="submit" type="submit" /></form> Do you think maybe a I should write 2 functions, one for all the fields(visible and non-visible) and one for the visible only. One function for each registration scenario? Edited December 4, 2012 by jimfog Link to comment Share on other sites More sharing options...
kanchatchai Posted December 4, 2012 Share Posted December 4, 2012 (edited) change <form action="register_form.php" method="post"> to <form action="register_form.php" method="GET"> and get variable you need in address bar after complete change it back Edited December 4, 2012 by kanchatchai Link to comment Share on other sites More sharing options...
jimfog Posted December 4, 2012 Author Share Posted December 4, 2012 change<form action="register_form.php" method="post"> to <form action="register_form.php" method="GET"> and get variable you need in address bar after complete change it back I did not quite understand the last phrase after..."complete change it back". Do you mean, to convert the GET variables to POST? And something else...I do not think it is good from a securitypoint of view to pass registration variables in a GET array-these must always be hidden, so the POST method is preferred here. Link to comment Share on other sites More sharing options...
rahultailwal Posted December 4, 2012 Share Posted December 4, 2012 Make two string of html. one for first option selected and second for second options. When first radio checked then load first string in a div and if second checked then remove the inner html of that div and replace with second string. Link to comment Share on other sites More sharing options...
jimfog Posted December 4, 2012 Author Share Posted December 4, 2012 I am going to do something else after all. Link to comment Share on other sites More sharing options...
kanchatchai Posted December 6, 2012 Share Posted December 6, 2012 i mean you can see variable in addressbar after change post to getlike thishttp://ie.microsoft.com/testdrive/ieblog/2008/Sep/09_TheIE8SmartAddressBarPart1NavigateEasierandFaster_2.pngand after you see variable change to Post again. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now