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. 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! 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 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? 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... 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! Link to comment https://forums.phpfreaks.com/topic/119986-solved-form/#findComment-618578 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.