views:

103

answers:

2

Hello all. Ii am trying to make a checkbox (to send via email) sticky.

To make sure it doesn't make a problem when sent empty I used the following:

<input type="checkbox" name="something" value="1">

<input type="hidden" name="something" value="0">

I have used things such as:

<input type="checkbox" name="something" value="1" <?=(($_POST['something']=='1')?'checked="checked"':'')?>>

But it does not work. Can someone please help me? Many thanks Francesco

A: 

Do you mean checked? If so then it would be

<input type="checkbox" name="something" value="1" checked />

Hope I understood that correctly

Jakub
Your markup contradicts itself. If you're using XHTML you have to use `checked="checked"`. If you're using HTML, then the self-closing part `/>` is invalid.
Joey
My post is not showing a php code that I have inserted..don't know why
francesco
Format it as code, then it works. I've done that for you.
Joey
Done, thank you.
francesco
+1  A: 

One could interpret that sticky means that user cannot uncheck the checkbox. That would be achieved using disabled="disabled" attribute.

As a side note, however, it wouldn't be very polite to force people to subscribe to some email list...

Jawa