views:

291

answers:

8
+2  A: 

It would probably help if you could explain a bit more about how you want the stuff to interact. That said, no law says a form can only have one submit button, and, when submitted it is possible to figure out which button is clicked--the name/value (text) of the button appear in the posted data. Exactly how to handle that really goes to what needs to happen and how you want to architect it, but you can definitely give a form multiple buttons.

--UPDATE--

Thanks for the clairifications. I think your best bet would be to use normal links and style them a bit:

a.button { display: block; width: 100px; float: left; }

They should be nice big clickable things in iTouches and in other more modern mobiles and degrade nicely in older mobile stuff as there really ain't nothing that can do HTML that doesn't support links.

Wyatt Barnett
Yeah i may have to work with floating which can give unpredictable results at times but I may not have a choice.
Programmin Tool
Well, if you want to be certain of predictable results, this is one of the few cases where using a table for layout might be permissible. Another good graceful degredation model would be to wrap the links in floated LIs, as that should drop down to a bulleted menu for devices that can't handle that level of CSS.
Wyatt Barnett
You know, I totally forgot about tables due to mobile sites frowning on them. I might have to go that direction if I can't get this too look right using floats and divs. Interesting second idea.
Programmin Tool
Honestly--the only way to know what happens is to build it and see how the browsers respond. It still is very wild west out there. Kinda like desktop browsers in the late 90s. The one thing you want to avoid here is to actually do this navigation via buttons and HTTP POSTs--mobile round trips are extra precious, and POSTing then redirecting gets you an extra one.
Wyatt Barnett
+2  A: 

If I understand what you are asking, then sorry there is no such function. You would have to find or create your own method that would identify the client and then output the correct HTML code and CSS to accommodate that device. It may be better to find a solution on the user side of the code. You could maybe use display:inline; to forge the button to act like an inline element no matter what. It should work in all major browsers (http://www.quirksmode.org/css/display.html), and this this probably includes the iPhone browser because it is safari based.

teh_noob
Yeah I had a bad feeling that the only way out of this was too start screwing with the display values, but that can be unpredictable. Such is life.
Programmin Tool
A: 

If you are not collecting data from the user, than they just look like simple links.

Tony Borf
If you mean they basically are links, you are correct. However links can be a real pain to touch on things like iPhones/iTouches.
Programmin Tool
+1  A: 

this might solve your problem

another solution: if you can use javascript, make a DIV and a onclick action on it

like what Jeff did here on SO with the [Votes] | [Answers] | [Views] "button" on the home page on the left side of every question

Fredou
Good link but images may not be an option due to speed.
Programmin Tool
look at my updated answer
Fredou
Some phone browsers don't allow javascript which could be an issue. I think I'm screwed.
Programmin Tool
A: 

HTML buttons don't have to be inside forms. You can have a button with a javascript onclick handler that does whatever you want, like setting a form's action and submit it, or load a new document.

<input type="button" value="Home"
  onclick="location.href='/index.php'" />
<input type="button" value="Rooms"
  onclick="var f=document.getElementById('myform');f.submit()" />
<input type="button" value="Create"
  onclick="var f=document.getElementById('myform');f.action='/create.php';f.submit()" />

Those buttons can then be styled in any way.

If your form isn't collecting data, then all your buttons can behave like the "Home" button in my example.

Alsciende
Problem is, some phones don't dig javascript. Im not beyond having multiple versions of the site for different phones but I just wanted to see if I could get around this.
Programmin Tool
+1  A: 

Use css to style anchor links like buttons. That way you get rid of the useless forms and maintain affordability and clickability.

Alsciende
Eh links being inline can't be given a specific width like buttons can. Using a div in the link would suggest I need to float or make inline. But an inline div can't be sized either.
Programmin Tool
You don't have to set a width. You can use padding, can't you? And if you want to set a width, then you are entitled to use a table:)
Alsciende
Sadly phones like razors don't like padding. I think the moral of the story is not to bother with phone sites :)
Programmin Tool
+1  A: 

I haven't tried this so I can't say if it will work or not, but could you not just set the forms on the page to "display:inline"?

dhulk
+1  A: 

When you post a form, the name attribute of the button used to post it is sent as a form value. Give each button a name, and then check the Form collection (or an Asp.Net MVC intermediary) for the button's name.

if(!String.IsNullOrEmpty(Request.Form["myButtonName"])) {
    //myButtonName has been pressed.
}

EDIT:

Problem is that turns out a form is a block element so that it's not possible to get to button next to each other. (Why they are block elements I'd like to know.)

Forms are block elements because if they were inline elements it would be invalid to nest tags like p and div inside of them (both of which are handy in constructing forms).

AaronSieb
Ah forms as blocks makes sense now. Thanks for that.
Programmin Tool