houssam_ballout Posted January 26, 2008 Share Posted January 26, 2008 Helo all, I am building an applications using php, I'd created a page where the user can add questions. I gave him the option to add different answers by selecting the number of options from a drop-down box. The code below is running but I'd to click the button to add my number of boxes, I want to make in a way , that when I select the number of boxes from the drop-down to create it automatically (in other way, call the form submit automatically)? Thanks in advance <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php if(isset($_POST['select'])) { $number = $_POST['NbOptions']; for($i=0;$i<$number;$i++) echo "<input type='text' name='option$i' /><br />"; } ?> <form name="test" method="post"> <select name="NbOptions"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> </select> <input type="submit" name="select" /> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
revraz Posted January 26, 2008 Share Posted January 26, 2008 You want them to create without hitting submit? If so, you need Javascript. Quote Link to comment Share on other sites More sharing options...
haku Posted January 26, 2008 Share Posted January 26, 2008 Ya, this can't be done with PHP. If you get them to hit submit it can though, although it will require a call to the server, and the page will have to reload. 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.