A user logs in to his control panel and sees his incoming messages. Near each message there is a "Reply" button. What is the correct way to implement that button?
I see three main options:
Use a link:
<a href="customer.php?reply&messageid=1234">Reply</a>.Disadvantage:
- We need to style that link to look like a button. Because I think that action "Reply" should be represented by a button, not a link (in my opinion links should be used when they link to some resource and when we have a noun in link text; and if we want to make an action and have a verb (action) in a caption - button should be used).
Use a button:
<button onclick="location.href='customer.php?reply&messageid=1234'">Reply</button>`Disadvantage:
- The user must have JavaScript enabled. Though based on our statistics 99.8% of our users have JavaScript enabled, and if they don't it will be really difficult for them to work on our website anyway (we have many features implemented with JavaScript). So I think that 100% of our actual active users have JavaScript enabled.
Use a form with
<input type="submit">:<form action="customer.php?reply" method="get"> <input name="messageid" type="hidden" value="1234" /> <input type="submit" value="Reply" /> </form>Disadvantage:
- I think using form here is "artificial". A user doesn't enter anything. We use the form just to make our button work. I also think that using POST request when we don't change anything and just need to show a reply form to a user - violates REST principles. But even with using GET I still think that using form is artificial in this case.
Some other notes:
- Using a button inside a link doesn't work in IE.
- It's a private section of our website so search engines can't see it and we don't really need a link to help search engine follow it and index the resource (it's a usual argument for using links in web instead of buttons)
Which one would you choose and why?
UPD. Well, I have decided to use a link. Thank you everyone for discussion!
<button>s submit a form too, if you want something more stylable than<input type="button">...