Forum Moderators: mack

Message Too Old, No Replies

2 actions from one form

         

bysonary

2:30 pm on Jan 29, 2007 (gmt 0)

10+ Year Member


Hello, I currently have the below code

<form method="post" action="delete.php">
<select name="OS" SIZE=3>

<?
$dir = "/home/www/juttuffi/gallery/images";
$d = opendir($dir);
$type = array(IMAGETYPE_GIF,IMAGETYPE_PNG,IMAGETYPE_JPEG,IMAGETYPE_BMP);

while($entry = readdir($d))
{
if ($entry!= "." && $entry!= ".." && array_search(exif_imagetype($dir."/".$entry),$type)!== false)
{
echo "<option>".$entry."</option>";
}
}
echo '</select>';
?>
</select>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>

as you can see the <form action ="delete.php">

I want to make it so this form has 2 buttons and each button performs a different action, one action is to delete and the other action is to view, so there are 2 actions within the one form can this be done if so can anyone tell me the HTML for it?

Thanks

jatar_k

1:19 pm on Jan 31, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you would need to have 2 buttons and no actual submit button. You can then use javascript to check which button was clicked and submit the form to the appropriate page.

Nutter

3:09 pm on Feb 1, 2007 (gmt 0)

10+ Year Member



I've done the same thing with two submit buttons with the same name, but different values. Then the script checks the value of the submit variable passed.

<input type="submit" name="submit_button" value="Delete">
<input type="submit" name="submit_button" value="Edit">