B34ST Posted June 16, 2007 Share Posted June 16, 2007 Hi, I have a form where users can input step by step guides. There is no limit on the number of steps for each guide so instead of displaying a set amount of input boxes I want to add just one named step1 then if the user requires a step 2 they can click add another step and another box pops up under step 1 named step 2 etc I dont want any of the informatin to be submited untill the user has stopped adding steps and clicks the submit button. I am not sure if this can be done with php? any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/55872-solved-dynamic-forms/ Share on other sites More sharing options...
The Little Guy Posted June 16, 2007 Share Posted June 16, 2007 you will need javascript to do this. Quote Link to comment https://forums.phpfreaks.com/topic/55872-solved-dynamic-forms/#findComment-276022 Share on other sites More sharing options...
B34ST Posted June 16, 2007 Author Share Posted June 16, 2007 I was thinking possibly javascript but wouldnt know where to start ??? Quote Link to comment https://forums.phpfreaks.com/topic/55872-solved-dynamic-forms/#findComment-276025 Share on other sites More sharing options...
Pastulio Posted June 16, 2007 Share Posted June 16, 2007 What exactly are you going for? so a user inputs something and clicks a "button" to get another input box? Quote Link to comment https://forums.phpfreaks.com/topic/55872-solved-dynamic-forms/#findComment-276028 Share on other sites More sharing options...
B34ST Posted June 16, 2007 Author Share Posted June 16, 2007 yes that would work Quote Link to comment https://forums.phpfreaks.com/topic/55872-solved-dynamic-forms/#findComment-276029 Share on other sites More sharing options...
Pastulio Posted June 16, 2007 Share Posted June 16, 2007 Well first of all you'd need a to make a button with an onclick:"" that triggers the function that adds another box in javascript. I'm gonna look something up on google for your specific needs and I'll keep you posted. (I don't know javascript but I'm always willing to learn myself). Quote Link to comment https://forums.phpfreaks.com/topic/55872-solved-dynamic-forms/#findComment-276031 Share on other sites More sharing options...
The Little Guy Posted June 16, 2007 Share Posted June 16, 2007 Javascript/HTML <script type="text/javascript"> function add_file(id, i) { if (document.getElementById(id + '_' + i).innerHTML.search('uploadinputbutton') == -1) { document.getElementById(id + '_' + i).innerHTML = '<textarea class="uploadinputbutton" name="step[]"></textarea><br /><span id="' + id + '_' + (i+1) + '"><input type="button" value="Add Another Step" onClick="add_file(\'' + id + '\', ' + (i+1) + ');" /><\/span>\n'; } } <form action="view.php" method="post"> <textarea class="uploadinputbutton" name="step[]"></textarea> <br> <span id="file_1"> <input value="Add Another Step" onclick="add_file('file', 1);" type="button"> </span> </form> PHP (view.php) <?php echo '<ol>'; foreach($_POST['step'] as $step){ echo '<li>'.$step.'</li>'; } echo '</ol>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/55872-solved-dynamic-forms/#findComment-276032 Share on other sites More sharing options...
Pastulio Posted June 16, 2007 Share Posted June 16, 2007 ok you beat me to it, bravo Quote Link to comment https://forums.phpfreaks.com/topic/55872-solved-dynamic-forms/#findComment-276033 Share on other sites More sharing options...
B34ST Posted June 16, 2007 Author Share Posted June 16, 2007 Thats great thanks a lot Quote Link to comment https://forums.phpfreaks.com/topic/55872-solved-dynamic-forms/#findComment-276034 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.