using input type="button" does not work with if(isset($_POST['button-name']))
Here's something i was trying tonight.
A form with 3 buttons(!).
I kept all 3 in the same <form> element just to see,...
the first button, submit works as expected,
the second button at first i had coded like this:
when coded as type="button" it did not respond to this...
<input type="button" name="reset-page-copy" value="reset to default" />
but when coding as type="submit" or .....
//run some code
...the if isset statement worked.
<input type="submit" name="reset-page-copy" value="reset to default" />
why is that?? i never came across this before.
and how can i use input type="button" instead of input type="submit" ??
big thanks everyone
You could add a type="hidden" input element to check for.
thanks but not sure what you mean. check for what?,
it's not critical of course, i can use input type="submit" instead of input type="button" but am curious why,... what that difference is,
Frankly, I've never used type="button", so I'm not sure if you are encountering a browser-specific problem or a general HTML issue. What does a button-type provide for you that a submit-type does not? Alternatively, you could use a button element with type="submit", perhaps?
i don't think buttons get 'set'. They're just there, see?
What you need is something like was_pressed($_POST[your_button])
<input type="button" name="mybutton" id="mybutton" onclick="dostuff()" />
// the code you want done when the button gets clicked
By the way there is an <input type="reset" ... /> that will reset all fields in the form to their original values FOR you, if you didn't know
Last edited by captainscall; 07-22-2012 at 03:37 PM.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)