ashbullmanuk Posted December 7, 2009 Report Share Posted December 7, 2009 Hi everyone, I am trying to add a conditional if statement to a checkbox in an html form, so that when the user checks the box, the a new set of form elements appear below it. I created the new form elements in a seperate file, and planned on using the include command, so something like: If ('kick start' == "yes" { include ('kickstart.html');} the html check box code is Kick Start nothing happens though when i click the checkbox. Any thoughts? Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted December 8, 2009 Report Share Posted December 8, 2009 Javascript is what you need, but I'm not a js guru. Quote Link to comment Share on other sites More sharing options...
Wickham Posted December 8, 2009 Report Share Posted December 8, 2009 Could you use chained select boxes with javascript? See this:- http://www.dynamicdrive.com/dynamicindex16/chainedselects/index.htm Quote Link to comment Share on other sites More sharing options...
ashbullmanuk Posted December 8, 2009 Author Report Share Posted December 8, 2009 i checked out the link, but what i need is that when a user checks a box a whole new section of form appears, with text fields and areas etc. I dont know much about JS either, so if anyone knows where i might help or a tutorial on this or with PHP would be very much appreciated. I found a source with what looked like it could do what i want, but the page threw a 500 internal server error when loading the it. the new code if anyone maybe able to shed some light is: <?php //Defining checkbox variable $kick_start = 'unchecked'; if(isset($_POST['continue'])) // the continue button to execute the following { if ?(isset($_POST['kick_start'])) { $kick_start = $_POST['kick_start']; if ($kick_start == 'yes') { include("kick_start_form.html"); } } } ?> Many thanks everyone Quote Link to comment Share on other sites More sharing options...
Wickham Posted December 8, 2009 Report Share Posted December 8, 2009 You can make a show/hide or expand/collapse section with javascript or PHP. Here is a PHP example, the benefit being that it works even if javascript is disabled:- Item 1 just happens to be a hidden form, but it could be anything:- http://www.wickham43.net/showform.php Quote Link to comment Share on other sites More sharing options...
BeeDev Posted December 8, 2009 Report Share Posted December 8, 2009 maybe try removing the typos first: if ?(isset($_POST['kick_start'])) the question mark above looks like a typo to me Quote Link to comment 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.
Note: Your post will require moderator approval before it will be visible.