PHP_Idiot Posted April 5, 2009 Share Posted April 5, 2009 Hi as you may of guessed from the screen name I'm new to this. I need to develop a page that records tournament information and feeds it back into my database. I have a drop down list that calls venue names from my database, another to enter the date field and a third to ask how many players results need recording. what I need the form to do then is create the required number form input rows ( same as number of player results that need recording). The form would end up with number of players listed 1,2,3 (these become their finishing positions) etc running top to bottom, next would be an input field for the players membership number, thirdly, a ldisplay box that looks up the membership number and displays the players name as a sanity check. Then when the user submits the form it saves the data to the mysql database. I can make a static form but how do I get it to change the number of form rows available to match the user inputted player results number? Thanks for all advice offered. Link to comment https://forums.phpfreaks.com/topic/152611-php-forms-adding-user-specified-number-of-form-rows/ Share on other sites More sharing options...
mentalist Posted April 5, 2009 Share Posted April 5, 2009 It depends on how you want to do it... If they enter the number of players and submit the page, then get that number and use it to generate the number of entries. If you don't want them to submit it then it becomes a javascript issue, where you'll want to look at 'innerHTML'. Your sanity check might even require the use of AJAX unless you submit the form... Link to comment https://forums.phpfreaks.com/topic/152611-php-forms-adding-user-specified-number-of-form-rows/#findComment-801514 Share on other sites More sharing options...
PHP_Idiot Posted April 5, 2009 Author Share Posted April 5, 2009 Ummm... not sure which is best. What i had in mind was a page to enter the inital info, so a drop down of current venues (which I already have working) the date played (also working) and then a text entry field to input the number of players. Then clicking the submit would take you to a form with the correct numbers of rows created. However, I had imagined that the sanity check would run once the membership had been entered, without clicking any further buttons! I tried the following code to create a loop but I can't get it to work, I was kinda hoping I could build it up from here! <? numplayers = 20; for ($i = 1; $i <= $numplayers; $i++ {echo ' <tr><table border="1"> <tr><th>Position</th><th>Membership Number</th><th>First Name</th><th>Last Name</th></tr> <td id="player.'$i'"><label>Position</label><input name="1" type="text" value="1" size="2" maxlength="2"></td> <td><label></label><input name="membership" type="text" size="7"></td> <td><label></label><input type="text" size="15" maxlength="10"></td> <td><input type="text" size="15" maxlength="10"></td> </tr>'; } ?> Link to comment https://forums.phpfreaks.com/topic/152611-php-forms-adding-user-specified-number-of-form-rows/#findComment-801613 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.