Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

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

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

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>
stephenrodrics
New php-forum User
New php-forum User
 
Posts: 57
Joined: Thu Mar 14, 2013 6:10 am

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.
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 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
stephenrodrics
New php-forum User
New php-forum User
 
Posts: 57
Joined: Thu Mar 14, 2013 6:10 am


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.