Jump to content

Recommended Posts

Hi

I'm totally green when it comes to php, but am learning it the hard way. Any help is appreciated.

 

I have a form the currenty uses a custom taxonomy but it has a text field, and I want it to call and list the taxonomy items with checkboxes so instead of entering words the visitor can just multiple check off the taxonomies that relate to them.

 

It's a job board, this is the job skill part that relates to their expertise.

 

There is a job category in the form, and I tried to use the syntax to get the taxonomy and implode it but 

 

I really don't know what I'm doing.

 

See the "skills" item? I want to make that a bunch of checkboxes to allow selection the the pre defined resume_skills taxonomy.

 

http://outsourcing.jadesource.com/submit-resume-free/

 

Any help would be great, and I'm not sure what code I need to put in here.

 

Mark

Checkboxes work by assigning ALL of them the same 'name=' attribute.  Your html for a checkbox would look like:

 

<input type='checkbox' name='skills[]' value='1'><label> Skill 1</label>
<input type='checkbox' name='skills[]' value='2'><label> Skill 2</label>

Create as many of these as you need with each having a unique value attribute and label.  Then in your php code you will create a loop to go thru the returned $_POST elements that will be in the 'name' index in an array.

 

 

$invalid_skill = false;
$have_skills=false;
foreach ($_POST['skill'] as $skill)
{
    if (!in_array($skill,array(1,2,3,4,5)))
    {
         $invalid_skill=true;
    }
    else
    {
        $have_skills = true;
    }
}
if (!$invalid_skill)
{
    $err_msg = "You have an invalid skill";//  user hacked the form and produced something wrong
}
if (!$have_skills)
{
    $err_msg = "You must provide a skill";
}
 

 

Of course you can use the literal value of the skills in the value clauses instead of a number, but I think this gives you something to work with.

 

Hope to see your code attempt soon!

Gingerjm gave you an excellent strart. I think that you will should store a default set of the skills in a database (you could hardcode them in the form but I would recommend against that) and produce the initial checkboxes from your list rather than from POST data. You'll still need a text input because you can't possibly anticipate everything.

David - I wasn't suggesting that the initial checkboxes be created from POST data.  As I showed - they are created manually.  They could be created via a query that pulls down 'value' items and 'literal' skill names to be used in the html, but I left that to the OP's imagination and skill level

  • Like 1

David - I wasn't suggesting that the initial checkboxes be created from POST data.  As I showed - they are created manually.  They could be created via a query that pulls down 'value' items and 'literal' skill names to be used in the html, but I left that to the OP's imagination and skill level

Sorry, I missed the manual creation. I believe that whether manually created or in a database, for the OPs purpose there needs to be an other box with the ability to put in freeform text if the box is checked. There is no way to compile a complete list of skills and keep it up to date.

Edited by davidannis
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.