tags:

views:

35

answers:

1

The user sees a web form with a bunch of controls. One of them is a combo box (drop down list) with several options.

He selects one and hits the submit button. My PHP form action validates the input & shows the submission as a read-only version of the input form for confirmation.

I would like to prevent the combobox from dropping down, using only HTML generated by PHP.

Can I?


Edit: I need to display it as it was in the original form (WYSIWYG), so can't just use plain text

+3  A: 

I think this is what you're looking for:

select#some-id { color: black; }

<select id='some-id' disabled='disabled'><option value='some-value'>Text to Show</option></select>

The CSS is to prevent the "grayed out" behaviour of a disabled form element. The little tick next to the text field will still be grayed out, which intuitively suggests that drop-down is not available.

Kivin
"which intuitively suggests that drop-down is not available" - despite the fact that it still is :-) Thanks, though (+1). I might end up using this.
Mawg
Hey mawg. If disabled=disabled attribute is included, the drop-down is indeed unavailable. At least, that is the case in Firefox. I didn't cross-test, tbqh.
Kivin
The styling of the color doesn't work in IE8, but it is indeed disabled.
Zerofiz
And actually, you can just use <select id='some-id' disabled><option value='some-value'>Text to Show</option></select>and it still works.
Zerofiz
@Zerofiz, you can definitely do that in any smart browser and plenty of stupid ones, to boot. But that breaks XHTML1 parsing if that is a design goal :)
Kivin
I guess what I'm finding out is that there just isn't a cross-browser compatible way to have your cake and eat it, too. Hmm.
Kivin