The Little Guy Posted October 10, 2007 Share Posted October 10, 2007 OK, what is the best way do a form within a form? I have a list of files, one form is to delete the files, and the other is to give each file a title. The large form is one so users can select which files they would like to delete. (Red Border (in attachmet)) The small forms are within this to rename each file, and this is done using AJAX. (Green Border (in attachmet)) Basically what is happening, is that it is submitting the Red form, when I try to submit a green form. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/72679-forms-within-a-form/ Share on other sites More sharing options...
Barand Posted October 10, 2007 Share Posted October 10, 2007 HTML does not allow nested forms. Link to comment https://forums.phpfreaks.com/topic/72679-forms-within-a-form/#findComment-366470 Share on other sites More sharing options...
The Little Guy Posted October 10, 2007 Author Share Posted October 10, 2007 I know, I need a way to fix this, so what would the best way be? Link to comment https://forums.phpfreaks.com/topic/72679-forms-within-a-form/#findComment-366471 Share on other sites More sharing options...
marcus Posted October 10, 2007 Share Posted October 10, 2007 <table border=0 cellspacing=5 cellpadding=8> <tr> <td><!-- ADD TITLE THING HERE --></td> <td><!-- ADD TITLE THING HERE --></td> <td><!-- ADD TITLE THING HERE --></td> <td><!-- ADD TITLE THING HERE --></td> </tr> <tr> <td><!-- IMAGE + DELETE CBOX HERE --></td> <td><!-- IMAGE + DELETE CBOX HERE --></td> <td><!-- IMAGE + DELETE CBOX HERE --></td> <td><!-- IMAGE + DELETE CBOX HERE --></td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/72679-forms-within-a-form/#findComment-366472 Share on other sites More sharing options...
The Little Guy Posted October 10, 2007 Author Share Posted October 10, 2007 could I use Javascript, to build post or get variables to send with the large form? then just place the form around that bottom button, so that way I don't have nested forms? Link to comment https://forums.phpfreaks.com/topic/72679-forms-within-a-form/#findComment-366478 Share on other sites More sharing options...
Barand Posted October 10, 2007 Share Posted October 10, 2007 You could have 4 little forms (green boxes) then begin the large form after those. Link to comment https://forums.phpfreaks.com/topic/72679-forms-within-a-form/#findComment-366481 Share on other sites More sharing options...
marcus Posted October 10, 2007 Share Posted October 10, 2007 You could some sort of get methods on how the form is sent. <form name="your_uploads" method="post" action="file.php"> <!-- TABLE --> <!-- INPUT BUTTON FOR SAVE TITLE COULD BE SUTTIN LIKE --> <input type="submit" name="submit" value="Save"> <!-- MORE TABLE + CBOX --> <input type="submit" name="submit" value="Delete Selected"> </form> <?php $method = $_POST['submit']; if($method == 'Save'){ //save title } if($method == 'Delete Selected'){ $file = $_POST['files']; foreach($file AS $woah){ unlink($woah); } } ?> Link to comment https://forums.phpfreaks.com/topic/72679-forms-within-a-form/#findComment-366482 Share on other sites More sharing options...
The Little Guy Posted October 10, 2007 Author Share Posted October 10, 2007 the large form is for deleting files (like I said), so... if I had it after the boxes, how would I get each check box? The only way I can think of is doing a javascript script to build a get extension, and append that to the end of the action in the form. Link to comment https://forums.phpfreaks.com/topic/72679-forms-within-a-form/#findComment-366483 Share on other sites More sharing options...
The Little Guy Posted October 10, 2007 Author Share Posted October 10, 2007 If I did that, then my delete would have to be AJAX as well... Link to comment https://forums.phpfreaks.com/topic/72679-forms-within-a-form/#findComment-366484 Share on other sites More sharing options...
marcus Posted October 10, 2007 Share Posted October 10, 2007 I've used a method like that before. <script language="Javascript"> function changeFormAction(x){ form_name.action = 'index.php?act='+x } </script> Could just call it using onClick or onFocus <input type="text" name="title" onFocus="return changeFormAction('title')"> Link to comment https://forums.phpfreaks.com/topic/72679-forms-within-a-form/#findComment-366485 Share on other sites More sharing options...
The Little Guy Posted October 10, 2007 Author Share Posted October 10, 2007 I've GOT it! here is what I will do... I will make some JavaScript that will take the clicked check box and add it between some span tags as a hidden field, this will contain all the values of the files that I want to delete. Then when the box is un checked, i will remove the hidden field from the span list. Link to comment https://forums.phpfreaks.com/topic/72679-forms-within-a-form/#findComment-366489 Share on other sites More sharing options...
Barand Posted October 10, 2007 Share Posted October 10, 2007 the check boxes would be inside the big (red) form. Only the 4 rename forms (green) would be outside. Link to comment https://forums.phpfreaks.com/topic/72679-forms-within-a-form/#findComment-366491 Share on other sites More sharing options...
The Little Guy Posted October 10, 2007 Author Share Posted October 10, 2007 But that isn't how my form is set up, and plus, there can be a limit of files showing between 4 and 60 all at once so there would be up to 60 green forms. Link to comment https://forums.phpfreaks.com/topic/72679-forms-within-a-form/#findComment-366498 Share on other sites More sharing options...
Barand Posted October 10, 2007 Share Posted October 10, 2007 I know it isn't how your form is set up. What's more, it doesn't work the way you have it set up. So having established that you cannot nest the green forms inside the red form, the obvious solution, to me anyway, is to move the green forms OUTSIDE the red form. Link to comment https://forums.phpfreaks.com/topic/72679-forms-within-a-form/#findComment-366504 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.