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><?phpif(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> Link to comment Share on other sites More sharing options...
jeffman Posted January 26, 2008 Share Posted January 26, 2008 Give this a try. I haven't tested it, but I feel pretty confident.<form name="test" method="post" id='test'><select name="NbOptions" onchange="this.form.submit()"> Link to comment Share on other sites More sharing options...
houssam_ballout Posted January 26, 2008 Author Share Posted January 26, 2008 It didnt work? Link to comment Share on other sites More sharing options...
Ingolme Posted January 26, 2008 Share Posted January 26, 2008 I'd do it this way:<form name="test" method="post" id='test'><select name="NbOptions" onchange="this.parentNode.submit()"> Link to comment Share on other sites More sharing options...
jeffman Posted January 26, 2008 Share Posted January 26, 2008 Yeah, that was my first thought. Then I got worried that a small change might turn a <center> tag (or something silly like that) into the parent node. But, hey, mine didn't work. This almost certainly will if ParentNode fails for some reason.<select name="NbOptions" onchange="document.getElementById('test').submit()"> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.