oracle259 Posted October 27, 2006 Share Posted October 27, 2006 How do I allow users to add as many additional input boxes as they need. eg i have a conference room booking solution which provides for 6 participants how do i allow users to add another input box for more than 6 participants or delete extra input boxes for less than 6 participants but 1 input box must remain. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/25345-need-help-coding/ Share on other sites More sharing options...
Caesar Posted October 27, 2006 Share Posted October 27, 2006 That's pretty vague. Can you maybe show some of your existing code and explain what you want your code to do? Is this on a page where users/the user needs to be logged in to edit the form? Quote Link to comment https://forums.phpfreaks.com/topic/25345-need-help-coding/#findComment-115552 Share on other sites More sharing options...
oracle259 Posted October 27, 2006 Author Share Posted October 27, 2006 i havent started coding this section bcause i knew it was going to give me troble so i decided to seek help first. But simply all i want to do i allow user s to click on a link that says 'add more members' when they click the link an additional input box appears and allows them to input the name of the individual. You can forget the delete part that seems overly complex Quote Link to comment https://forums.phpfreaks.com/topic/25345-need-help-coding/#findComment-115553 Share on other sites More sharing options...
sasa Posted October 27, 2006 Share Posted October 27, 2006 try [code]<html><head><script language="JavaScript1.3" ><!--function row(){ var table=window.document.getElementById("table1"); var newRow = document.createElement("tr"); var newCell=newRow.appendChild(document.createElement("td")); var input=newCell.appendChild(document.createElement("input")); input.type="text"; input.name="frend[]"; table.appendChild(newRow);}--></script></head><body><?phpif ($_POST) { //for ($x=0;$x<5;$x++) $c["cell".$x]=$_POST['cell'.$x]; print "<pre>"; print_r($_POST); print "</pre>";}?><form method="POST" action=""><input type="button" value="AdRow" onclick="row()"><input type="submit"><br /><table id="table1" border="3px" width="20%" align="left" > <tr> <td width="20%" align="center">FREND</td> </tr></table><br /></form></body></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/25345-need-help-coding/#findComment-115605 Share on other sites More sharing options...
oracle259 Posted October 30, 2006 Author Share Posted October 30, 2006 Thanks it works. But im curious how do i amend the code to delete unwanted input boxes. For example i add the same person at boxes 3 and 8 of 21 how do i amend the code to allow users to delete each individual input box. May be i could add a link beside each input box that when click deletes that specific input box.If you have any ideas pls tell me.Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/25345-need-help-coding/#findComment-116830 Share on other sites More sharing options...
oracle259 Posted October 30, 2006 Author Share Posted October 30, 2006 also how can i modify the jscript to allow for multiple input boxes in the same row. For example say that row 1 as 3 input boxes, same a row 2 but i want a 3rd row which must also have 3 input boxes how do i go about accomplishing that.Thanks again 4 ur help Quote Link to comment https://forums.phpfreaks.com/topic/25345-need-help-coding/#findComment-116848 Share on other sites More sharing options...
sasa Posted October 30, 2006 Share Posted October 30, 2006 [code]<html><head><script language="JavaScript1.3" ><!--var count = 0;function row(){ count = count +1; var table=window.document.getElementById("table1"); var newRow = document.createElement("tr"); newRow.id = 'row'+count; var newCell=newRow.appendChild(document.createElement("td")); for (var i=0;i<5;i++){ var input=newCell.appendChild(document.createElement("input")); input.type="text"; input.name="frend["+count+"][]";} var a = newCell.appendChild(document.createElement("a")); a.href="javascript:moveRow("+count+")"; a.innerHTML ='Remove row'; table.appendChild(newRow);}function moveRow(i) { var row = document.getElementById("row"+i); row.parentNode.removeChild(row);}--></script></head><body><?phpif ($_POST) { //for ($x=0;$x<5;$x++) $c["cell".$x]=$_POST['cell'.$x]; print "<pre>"; print_r($_POST); print "</pre>";}?><form method="POST" action=""><input type="button" value="AdRow" onclick="row()"><input type="submit"><br /><table id="table1" border="3px" width="80%" align="left" > <tr> <td width="20%" align="center">FREND</td> </tr></table><br /></form></body>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/25345-need-help-coding/#findComment-116964 Share on other sites More sharing options...
oracle259 Posted October 30, 2006 Author Share Posted October 30, 2006 Thanks so much the script works perfectly. Im so happy right now you wouldnt believe. :D Quote Link to comment https://forums.phpfreaks.com/topic/25345-need-help-coding/#findComment-116985 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.