Jump to content

Checkbox question


shock

Recommended Posts

Hi,

 

I am creating an email form with checkbox included.

 

And I need the checkbox to be ticket when I enter the form though links.

 

IE

 

List of checkbox's

 

checkbox 1

checkbox 2

checkbox 3

checkbox 4

 

say I was another page and I click on a link (call the link checkbox 1) I would like the checkbox to be ticked automatically.

 

I know this makes no sense but I hope you get the idea.

 

Thanks in advance.

 

Lee

Link to comment
https://forums.phpfreaks.com/topic/55062-checkbox-question/
Share on other sites

You need the checked="checked" attribute of the HTML <input /> tag...

 

you could do sth like this... if i understand what you need...

<?php
if ($_GET['checkbox1'] == "check")
{
     $check1 = ' checked="checked" ';
}
echo '<input type="checkbox" name="name" value="value"'.$check1.'/>';
?>

 

any variation to make the above code more effective is what you need, especially if you have more checkboxes but i guess you get the point... this is it more or less...

Link to comment
https://forums.phpfreaks.com/topic/55062-checkbox-question/#findComment-272201
Share on other sites

that is what i am saying in my post...

 

you just have to add checked="checked" to the checkbox you want checked. if you want to do it using $_GET vars you should check the vars

if (isset($_GET['check']))
{
    switch($_GET['check'])
    {
          case 1:
            $check1 = ' checked="checked" ';
          case 2:
            $check2 = ' checked="checked" ';
    }
}

i hope i am understandable now...

Link to comment
https://forums.phpfreaks.com/topic/55062-checkbox-question/#findComment-272211
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.