943,708 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 6434
  • PHP RSS
Aug 20th, 2006
0

How to pre-select checkboxes in form?

Expand Post »
Greetings,
I need help with preselecting checkboxes in a HTML form.

The first form has several checkboxes and then I post this to a php page which based on the checkboxes selected will send out emails. Each check box corresponds to an email address. After I send an email to selected people, I then at a later point would like to send an update email. The second form should be pulling up information regarding these checkboxes and select boxes accordingly.

The checkbox portion in the form looks like this!


PHP Syntax (Toggle Plain Text)
  1.  
  2. <INPUT TYPE=CHECKBOX NAME=dl[] VALUE=john@email.com>John
  3. <INPUT TYPE=CHECKBOX NAME=dl1[] VALUE=rambo@email.com>Rambo
  4. <INPUT TYPE=CHECKBOX NAME=dl2[] VALUE=everyone@email.com>Everyone


I then post the above to a PHP page, which then inserts these values into mysql database. I use array_merge to merge the values into a string into a database. When inserted, it get inserted as john@email.com,rambo@email.com,everyone@email.com. My second form has the same checkboxes but I am clueless regarding reading the checkbox values back and checking the boxes automatically.

Please advise!

Thank you in advance,
- Gravis
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Gravis is offline Offline
4 posts
since Aug 2006
Aug 20th, 2006
0

Re: How to pre-select checkboxes in form?

Use the "checked" option.

PHP Syntax (Toggle Plain Text)
  1. <INPUT TYPE=CHECKBOX NAME=dl[] checked VALUE=john@email.com>John

You'll likely want to bookmark this page:
http://www.w3.org/TR/REC-html40/interact/forms.html

A couple notes:
1. Always put your HTML options in quotes. If you get a space in the input field somewhere, it will interpret it up to the space.
2. Take care in placing the boxes to avoid ambiguity and save your users some trouble. Don't check them all "for" the user if the user is likely to uncheck them all.
Reputation Points: 23
Solved Threads: 23
Posting Pro in Training
Puckdropper is offline Offline
494 posts
since Jul 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Sending HTML message to Outlook
Next Thread in PHP Forum Timeline: Please Help! parse error, unexpected T_STRING





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC