Gossamer Forum
Home : Products : Gossamer Links : Discussions :

How do I checkmark in html if the user has checkmarked it before?

Quote Reply
How do I checkmark in html if the user has checkmarked it before?
Hi,

For some reason Im having a total brain fart, and can't remember how to do this.

I have the following:
Code:
<td><input name="decktheme" type="checkbox" value="Casual Play">Casual Play</td>

I would like to make it so that when the user modifys their record, if they already had the Casual Play option check marked, then it's check marked already for them when they go through the modify links modify.cgi page.

What extrac coding do I need to place in each checkmark option to do this?
Quote Reply
Re: [Westin] How do I checkmark in html if the user has checkmarked it before? In reply to
Hi,

Are you using more than one value for the checkboxes? If so, this would be better:

Code:
<%loop checkbox_loop%>
<input name="<%field_name%>" id="<%name%>" type="checkbox"value="<%name%>" <%if selected%>checked<%endif%> />
<label for="<%name%>"><%value%></label>
<%endloop%>

(from my ULTRAGlobals plugin)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] How do I checkmark in html if the user has checkmarked it before? In reply to
I'm not really sure what you mean.

I've got a series of checkboxes (about 20 of them), and they are all in one field in the database, however, not using checkboxes in Links before Im not sure how it will actually add them to the database, Im guessing simply as option 1 option 2 option 3 option4 etc all in the one database field, which might not be such a good thing. Or does it add them some other way?.

The more I think about it, I should probably just make them into a drop down selection and only allow once choice for this item, instead of multiple choice and just make the user have to decide what theme his deck actually fits into instead of allowing them to be wishy washy and checkmarking all the options.

Thanks for your time.
Quote Reply
Re: [Westin] How do I checkmark in html if the user has checkmarked it before? In reply to
Hi,

If you have them all in one field, that fine (better than tons and tons of checkboxes ;))

Just use the code I gave you above (change the field name though, as that was just an example)

This will then work out if the checkbox has been selected, and if it has - it will pre-check it for your user.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!