I need to do a search based on a term entered into a text box. Simply: user clicks something and results are returned.
This is fairly straight-forward, except I’m having a bit of difficulty actually implementing it. The problem is, I want to do this as RESTfully as possible, so I don’t want to create a button as follows:
<input id="searchButton" type="button" value="Search" />
because this will POST the data to the server, and I don’t want to do a POST because I’m not changing the state of anything. I’m retreiving data based on the value in the search box
I’d like to have it as a simple link, such as:
<a href="/Controller/Action">Search</a>
but it has to be styled as a button. If I was using the input, I could have CSS similar to:
.standardButtonStyle {
background:url("../images/search_button.png") no-repeat scroll 0 0 transparent;
border:0 none;
color:White;
cursor:pointer;
}
but I don’t think I can apply this to the anchor tag. Can somebody tell me the right way to do this?
1) You can choose the method for your form. If you give the attribute “method=’GET'” in your form tag, the request will not be a post, but a get.
2) You can use an input element with the type “button” if you want to create a button.
3) You can put an image tag inside the anchor tag which has the search button png as its src.
I think you got a little caught up in the complexity. It might be good to step back a little and focus at one issue at a time. I don’t think, that you really need to make it as complicated as you seem to do it.