Jump to content

checkboxes


An7hony

Recommended Posts

how would i get checkboxes to work. I have tried:

 

$JobCategories = ($_GET['JobCategories[]']) ? $_GET['JobCategories[]'] : $_POST['JobCategories[]'];

 

html looks like:

 

<li><input name="JobCategories[]" type="checkbox" value="Admin" /> Admin</li>

<li><input name="JoCategories[]" type="checkbox" value="Campaigning" /> Campaigning</li>

 

Link to comment
https://forums.phpfreaks.com/topic/211284-checkboxes/
Share on other sites

what do you really want? If your intention is both category can be selected, and you want to store them in an array, use somthing like

if(!empty($_GET['JobCategories']))
  foreach($_GET['JobCategories'] as $x){
    $JobCategories[]  = $x;
  }

 

If your intention is to select any of the category, use radio button instead

Link to comment
https://forums.phpfreaks.com/topic/211284-checkboxes/#findComment-1101650
Share on other sites

that seems to be working.

 

Although how do i pull the results i.e

 

$message = '

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head></head>

<body>

<table>

<tr><td>Categories</td><td>' . $JobCategories . '</td></tr>

<tr><td>Company</td><td>' . $company . '</td></tr>

<tr><td>Title</td><td>' . $title . '</td></tr>

<tr><td>First Name</td><td>' . $firstname . '</td></tr>

 

If i put $JobCategories[] into this it throws me an error

Link to comment
https://forums.phpfreaks.com/topic/211284-checkboxes/#findComment-1101678
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.