s1yman Posted August 16, 2008 Share Posted August 16, 2008 Hi, I was wondering if it is possible to have a form where boxes change based on other fields. What I mean exactly is; If you have a form, each entry point will have two radio buttons one for "text" and the one for "picutre" If the text button is selected it will display a "text" box and if the other is selected it will display a "file" box (upload box). Does anyone know if this is possible and how I might go about writing a script for it? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/119986-solved-form/ Share on other sites More sharing options...
themistral Posted August 16, 2008 Share Posted August 16, 2008 You could try using 2 forms...the first holds your 2 radio buttons. Submit that form when an option is chosen. Use an if statement to include another form is radio button 1 is chosen, else show the other form. Give it a go and let us know how you get on! Quote Link to comment https://forums.phpfreaks.com/topic/119986-solved-form/#findComment-618127 Share on other sites More sharing options...
s1yman Posted August 16, 2008 Author Share Posted August 16, 2008 will do. I'll let you know v soon Quote Link to comment https://forums.phpfreaks.com/topic/119986-solved-form/#findComment-618136 Share on other sites More sharing options...
s1yman Posted August 17, 2008 Author Share Posted August 17, 2008 Having a bit of trouble retrieving the information once on the second form. First form; <form id="form1" name="form1" method="post" action="form2.php"> <input name="div0" type="radio" value="file" id="1div0" /> <label for="1div0">Image</label> <input name="div0" type="radio" value="text" id="2div0" /> <label for="2div0">Text</label></html> Second form; <?php $zero = $_GET['div0']; { print '<form id="form2" name="form2" method="post" action="form2pro.php">'; print '<input name="div0" type="'; print $zero; print '" value="" />'; print '<input type="submit" value="submit" /></form>'; } ?> Any ideas what I'm doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/119986-solved-form/#findComment-618556 Share on other sites More sharing options...
mrMarcus Posted August 17, 2008 Share Posted August 17, 2008 i can see right off the bat, you have named both your input's the same, "div0". if you are trying to create an array, you must add '[]' to the name .. only then can you have the same name for each input. <input name="div0[]" value="something"> as well, you form is using "POST", and you are trying to retrieve the data via $_GET .. this will not work as $_GET gathers it's values from the URL, ex. form.php?id=something&name=Peter, etc... Quote Link to comment https://forums.phpfreaks.com/topic/119986-solved-form/#findComment-618566 Share on other sites More sharing options...
s1yman Posted August 17, 2008 Author Share Posted August 17, 2008 oh yes, that was very stupid lol. I changed the $_GET to $_POST and it seems to work. Thanks MrMarcus! Quote Link to comment https://forums.phpfreaks.com/topic/119986-solved-form/#findComment-618578 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.