Jump to content

Recommended Posts

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

<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

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

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

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

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.