Stylizing Form Submits #50
thecodedrift
announced in
Thunked
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
"The buttons aren't styling" I remarked as I stared at the page in Camino and Safari. Testing on the Mac platform has been the absolute bane of my existence as of late, mostly because for some reason, these browsers in particular are very protective of their form widgets. Coming back to Cameron Adams' Entry on Styling Form Widgets, I found that none of the Macromedia examples were actually working for Camino/Safari, although they looked beautiful in Firefox. The submit button simply would not take the background settings. Interesting enough though, something of
input type="button"
styled perfectly.However, the value attribute of the button wasn't getting passed in. For the legacy code around Gaia, we have forms with more than one possible "submit" for an action. The most common case of this is preview and submit buttons we traditionally use in the forums. This left us with two scenarios:
or Button tags that wouldn't pass in their value to the PHP script (and shouldn't technically perform a submit either)
The final solution ended up being something right down the middle and using JavaScript to make up for Safari / Camino's shortcomings. Starting with a default submit button, we can replace it with a input
type="button"
node, and add a bit of JavaScript to theonClick
to make up for the stylized button's shortcomings. The first block of JavaScript goes into the head, and the second block can either go into anonLoad
handler or at the end of the form tag, depending on how soon you need the replacement.Replace
FORMID
andSUBMITBUTTONID
with the relevant values.Drawbacks
The largest drawback hands down is the addition of JavaScript. It's not something to depend on, and many steps were taken to ensure that the enhancement is progressive in nature.
Styled images will have to be styled to reflect the change from an input to a button node, and can be referenced via
button#idNameofElement
to apply all the necessary stylization.Beta Was this translation helpful? Give feedback.
All reactions