Jump to content

adding text box on demand


houssam_ballout
 Share

Recommended Posts

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...