Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8147331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:18:57+00:00 2026-06-06T14:18:57+00:00

i have html form i am using <a href="#" onclick="document.aa.submit()"> instead of submit button

  • 0

i have html form

i am using <a href="#" onclick="document.aa.submit()"> instead of submit button

my code will explain my problem better..

<html>
<form name="aa" action="aa.php" method="post">
<input type="checkbox" name="posts[]" value="1">
<input type="checkbox" name="posts[]" value="2">
<a href="#" onclick="document.aa.submit()">Delete</a>
<a href="#" onclick="document.aa.submit()">Move</a>
</form>
</html>

aa.php

<?php
print_r($_POST);
?>

results

Array ( [posts] => Array ( [0] => 1 [1] => 2 ) ) 

Now the question is:

How to know user clicked on delete or move?

Note:

i know if i used <input submit> it will fixes the problem

but i can’t use submit button for some reason

Note 2

the question is how to detect it by php.

Example:

    Array ( [posts] => Array ( [0] => 1 [1] => 2 ['submit'=>'delete']) ) 

if('delete'){
mysql_query("delete from...")
}
else{
mysql_query("update/move ....");
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:18:58+00:00Added an answer on June 6, 2026 at 2:18 pm

    You need to make some tweaks to the form so the Post value knows which option you are submitting

      <form name="aa" action="aa.php" id='aa' method="post">
    <input type="checkbox" name="posts[]" value="1">
    <input type="checkbox" name="posts[]" value="2">
        <a href="#" onclick="submit_function(this)" rel="delete">Delete</a>
            <a href="#" onclick="submit_function(this)" rel="move">Move</a>
            <input id="submit_type" type="hidden" name="task">
            </form>
    

    in js with jquery

    function submit_function( item ){
        if( item.rel == 'move')
        {
        document.getElementById('submit_type').value ='move'
        }
        else if( item.rel == 'delete')
        {
        document.getElementById('submit_type').value ='delete'
        }
    
        document.getElementById('aa').submit()
    
        }
    

    in php

     if( $_POST['task'] == 'move' )
    {
    //do move stuff
    }
    
        if( $_POST['task'] == 'delete' )
    {
    //do delete stuff
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a cancel button in a form: @using (Html.BeginForm(ConfirmBid,Auction)) { some stuff ...
I have the following code on a view: @using (Html.BeginForm()) { <div class=select-box form>
I have html form with submit button and input='file' control: <form action=/Profile/UploadFile enctype=multipart/form-data method=post
I have an HTML form using dojo and have the following code for a
In my ASP MVC 3 application, I have this form @using (Html.BeginForm()) { <input
I have an ASP.NET MVC form laid out something like this: @using (Html.BeginForm(null, null,
I have a webpage with a form, which looks kinda like this: @using (Html.BeginForm(MyAction,
I have a following problem, I have HTML form that uploads a file with
I have a simple html login form, deployed on Xcode using phonegap framework. When
I have two issues When I submit the character ' through my HTML form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.