2020 Posted July 17, 2020 Share Posted July 17, 2020 Hi Folks, Which html button do you use out of these ? Which one is html5 and which ones are old timers ? 1. <button type="submit">Search</button> Shouldn't this be: <button type="search">Search</button> Or it is still "type='submit' because it submits search request to db ? 2. https://www.w3schools.com/tags/att_button_type.asp <button type="submit" value="submit">Search</button> 3. https://www.htmlquick.com/reference/tags/input-submit.html <input type="submit" value="Send Data"> I am spoilt for choice. Which one should I stick to ? Or, you got a better simpler one that works with all types of html 5 and php ? Not interested in complicated css buttons as of now. Quote Link to comment Share on other sites More sharing options...
2020 Posted July 17, 2020 Author Share Posted July 17, 2020 (edited) Folks, Look at these 3 buttons: <button type="submit">Submit</button> <button type="submit" value="submit">Search</button> <input type="submit" value="Send Data"> Look at number 3: value="Send Data" That means, the "value=" represents the button label. Now, look at number 2: value="submit">Search</button> Definitely, the "value=" does not represent the button label. As this represents the button label: >Search</button> Q1. Why "value=" means 2 different things on 2 different buttons ? Usually, on input fields, the "value=" represents the user's input. So, what does the "value=" represent on button number 2 since it doesn't represent the button label ? Certainly not a user's input since user cannot type anything onto a search/submit button! Just what is going on here ? I am confused, like hell! Who'd like to enlighten me ? Thanks Edited July 17, 2020 by 2020 Quote Link to comment Share on other sites More sharing options...
Barand Posted July 17, 2020 Share Posted July 17, 2020 5 minutes ago, 2020 said: Usually, on input fields, the "value=" represents the user's input. The user doesn't input the value on checkboxes or radio buttons <button>s are just another type of html element which allow the programmer to set a value independent of its label. In the example below, the value of the clicked button would be sent in $_POST['gender'] <button name='gender' value='M'>Male</button> <button name='gender' value='F'>Female</button> 1 Quote Link to comment Share on other sites More sharing options...
kicken Posted July 17, 2020 Share Posted July 17, 2020 2 hours ago, 2020 said: Shouldn't this be: Perhaps you should look at what the possible values are for button's type attribute. While you're at it, read through the rest of the spec and you'll learn all sorts of things. Bookmark it so if you have a question later you can refer back to it. Quote Link to comment Share on other sites More sharing options...
2020 Posted July 17, 2020 Author Share Posted July 17, 2020 (edited) 2 hours ago, Barand said: The user doesn't input the value on checkboxes or radio buttons <button>s are just another type of html element which allow the programmer to set a value independent of its label. In the example below, the value of the clicked button would be sent in $_POST['gender'] <button name='gender' value='M'>Male</button> <button name='gender' value='F'>Female</button> Thanks! That was a very good example. Things clear now! I am going to make use of this button code now. use the buttons similar to drop down options! Edited July 17, 2020 by 2020 Quote Link to comment Share on other sites More sharing options...
2020 Posted July 17, 2020 Author Share Posted July 17, 2020 Only the last button works for me on my following thread. I got the button suggested to me on another forum. <button type="submit">Submit</button> <button type="submit" value="submit">Submit</button> <input type="submit" value="submit"> <button name=submit value=" ">Submit</button> https://forums.phpfreaks.com/topic/311105-why-insert-fails-with-prepared-statement/?tab=comments#comment-1579730 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.