Jump to content
Killersites Forums

Conditional IF statement to HTML form checkbox to add form elements


ashbullmanuk
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...