jlm Posted September 12, 2007 Share Posted September 12, 2007 First off, let me start out by saying I know just enough about PHP to be dangerous. My normal use if to take an existing PHP form and modify to do what I want, however over time I have started to create my own from scratch. Here's the issue I have right now. I have a form that lets users enter data and then when they submit the form, that data is emailed to me. Simple, right. Well, right now there are fields for them to enter the data for 5 projects on the same form. What I want to do is have a button that will basically say "click to here to add another field". When the button is clicked it adds another set of fields for them to enter information about a sixth project. Click the button again, adds another set of fields for information about a seventh project.....and so forth. I hope this makes sense. Now my question is, how do I go about setting up this script that will allow me to implement this feature in my form. Any help at all anyone can provide will be greatly appreciated. Thanks, John Quote Link to comment Share on other sites More sharing options...
Barand Posted September 12, 2007 Share Posted September 12, 2007 here's one way <?php if (isset($_GET['sub'])) { echo '<pre>', print_r($_GET, true), '</pre>'; } ?> <html> <head> <meta name="generator" content="PhpED Version 4.5 (Build 4513)"> <title>sample</title> <script language="javascript"> function addfields() { var newline = "Project ID <input type='text' name='projID[]' size='6'> Cost <input type='text' name='cost[]' size='8'><br>"; var extra = document.getElementById("extra"); extra.innerHTML = extra.innerHTML + newline; } </script> </head> <body> <form> Project ID <input type="text" name="projID[]" size="6"> Cost <input type="text" name="cost[]" size="8"><br> Project ID <input type="text" name="projID[]" size="6"> Cost <input type="text" name="cost[]" size="8"><br> Project ID <input type="text" name="projID[]" size="6"> Cost <input type="text" name="cost[]" size="8"><br> Project ID <input type="text" name="projID[]" size="6"> Cost <input type="text" name="cost[]" size="8"><br> Project ID <input type="text" name="projID[]" size="6"> Cost <input type="text" name="cost[]" size="8"><br> <div id="extra"></div> <input type="button" name="add" value="Add item" onclick="addfields()"> <input type="submit" name="sub" value="Submit"> </form> </body> </html> As there is no php involved I'll move this to the javascript forum Quote Link to comment Share on other sites More sharing options...
jlm Posted September 13, 2007 Author Share Posted September 13, 2007 Hmmm, for some reason (and I'm sure it's something I'm going) this is not working. I've even tried to take exactly what you have and just use it as a test. The form displays like this <img src="http://mosssite.com/testing/form.jpg/> and the add item button does not work. Again I thank you very much for you help and I'm sure I've done something wrong. Basically I've just pasted what you gave me into a file and named it test.html, put it on my webserver and that's it. Let me know if you any more information will help. Thanks Quote Link to comment Share on other sites More sharing options...
jlm Posted September 17, 2007 Author Share Posted September 17, 2007 Just bumping this, hoping I can get some advice on where I'm going wrong with this. Thanks in advance!!! Quote Link to comment Share on other sites More sharing options...
Stickybomb Posted September 25, 2007 Share Posted September 25, 2007 yeah i am pretty sure this would require some ajax to work. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 25, 2007 Share Posted September 25, 2007 I tested my code in IE and FF - no problems Quote Link to comment Share on other sites More sharing options...
Stickybomb Posted September 25, 2007 Share Posted September 25, 2007 yeah it does i just tested it no sure what his issue is Quote Link to comment Share on other sites More sharing options...
khalidorama Posted November 5, 2007 Share Posted November 5, 2007 Hi, I tested it . It worked. Great and many thanks. I am really proud of my browser! Regards Quote Link to comment 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.