Html submit value based on which button is clicked -


is possible submit hidden name value pair based on button clicked?

here's form:

<form action="post" action="">     <button>         <input type="hidden" name="vote" value="up"/>         vote up!     </button>     <button>         <input type="hidden" name="vote" value="down"/>         vote down     </button> </form>  

for reason, name value pair received latter (the first 1 got replaced). example user clicked on 'vote down', still $input['vote'] = up

does know how fix this?

this because put both of them in form parameters received server like

vote=up&vote=down 

assume access using php associative array received latest value in entries having same key. aside, why not just

<form action="post" action=""> <button>     <input type="hidden" name="vote" value="up"/>     vote up! </button> </form>   <form action="post" action=""> <button>     <input type="hidden" name="vote" value="down"/>     vote down </button> </form>  

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -