can anyone tell me and help me please what is this what im I trying to do: //this is just a question on my mind it is not yet implemented <html> <body> <pre> <form name = reservation method = post action = 'reservation.php'> bla:<input type = text name = bla > blo:<input type = text name = blo> no.passenger: <input type = text name = passenger > <input type = submit value = submit> </pre> </body> </html> what i want in here is that when i put a value in no.passenger another text field will be shown up depending to the input of the user like for example i put 4 in the text field passenger and a 4 text field will be shown up for me to put the names of the passenger. . . . . help me please with this.
This can be done, but it has nothing to do with PHP from where I understood. This could be done with JavaScript. For example, something like this : Javascript (MooTools or Prototype is required): The code should look similar to this, maybe you mean to make a mySQL query to check the id.passenger, and return the names or wathever you want, that would be ajax, it lets you make html requests by javascript and use the source code generated in the actual browser. Hope this helps. cya
<html> <head> <script type="text/javascript" language="javascript"> function changeInput(textbox) { i = textbox.value; a = true; var testDiv = document.getElementById('testDiv'); while(a) { if(testDiv.firstChild) { testDiv.removeChild(testDiv.firstChild); } else { a = false; } } for(j=0;j<i;j++) { var textB = document.createElement('input'); textB.name = 'test'+j; textB.type = 'text'; testDiv.appendChild(textB); } } </script> </head> <body> <pre> <form name="reservation" method="post" action="reservation.php"> bla:<input type="text" name="bla"> blo:<input type="text" name="blo"> no.passenger: <input type="text" name="passenger" onChange="changeInput(this)"> <div id="testDiv"></div> <input type="submit" value="submit"> </form> </pre> </body> </html> Code (markup): Try that. I hope it works. Visit my site for some tutorials if you need more.
lol@complete example. you can use Ajax and PHP for that too together. <div> fields to hide the fields , and show fields.. or pass the number of passenger number to a PHP handler script through Ajax (so no page refresh) and come back in PHP into a named <div> with that many fields. I aint coding anything for Free like that.