My Form Gets submitted on click of any button out of 2

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

stephenrodrics
New php-forum User
New php-forum User
Posts: 58
Joined: Thu Mar 14, 2013 6:10 am

My Form Gets submitted on click of any button out of 2

Postby stephenrodrics » Mon Apr 01, 2013 5:55 am

I have 1 form and 2 buttons placed on the form, whenever i click Submit- button or Click button my form gets submitted.

Can anyone tell what is the relation between Click button and sumbit one, why functionality is same regardless of the button I select

<form name="form2" method="post" action= "submitlogin.php">

<td class="label"><br><input type="submit" name="submit" value="Submit-" size="25" onclick="display()"></td>

<button id='button' onclick="ShowAll()" >Click </button>

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: My Form Gets submitted on click of any button out of 2

Postby seandisanti » Mon Apr 01, 2013 8:47 am

the answer is not in the code that you've presented. Most likely your 'ShowAll' function does the same thing as your submitlogin.php. maybe both just display the values? if you show the code for that file, and that function, you'd probably get a better answer.

stephenrodrics
New php-forum User
New php-forum User
Posts: 58
Joined: Thu Mar 14, 2013 6:10 am

Re: My Form Gets submitted on click of any button out of 2

Postby stephenrodrics » Mon Apr 01, 2013 11:57 pm

hi seandisanti,

no there is no relation between show all and display function.

even i commented the code inside ShowAll function still form gets submitted.

Is there anything related to POST event getting fired when I click on the buttons ?

I also did 1 change today, as I removed the 2nd button code outside the Form Tag Body

OLD code

<form name="form2" method="post" action= "submitlogin.php">

<td class="label"><br><input type="submit" name="submit" value="Submit-" size="25" onclick="display()"></td>

<button id='button' onclick="ShowAll()" >Click </button>

</form>


New Change

<form name="form2" method="post" action= "submitlogin.php">

<td class="label"><br><input type="submit" name="submit" value="Submit-" size="25" onclick="display()"></td>

</form>

<button id='button' onclick="ShowAll()" >Click </button> // Now ShowAll stopped working once its outside the Form Tag Body


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 1 guest