• I’m using cforms 8.7 to create job application forms that sit within posts categorised as ‘jobs’.
    I want to dynamically pull the names of the posts(job titles) into a pulldown field (selectbox) in the form. I understand I need to create an array of posts from the ‘jobs’ category(using query-posts I think) and use that array when defining the contents of the pull down list. My PHP isn’t good enough to figure the code for this and after searching through endless forum posts I can’t find the answer.

    I’ve put posts up on the cforms forum which I’m getting clues from but no answers.

    Can anybody enlighten me?

    Thanks

Viewing 1 replies (of 1 total)
  • Thread Starter renderghost

    (@renderghost)

    Ok I got the form half built.

    <?php
    
    $fields['label'][0]  ='Your Name|Your Name';
    $fields['type'][0]   ='textfield';
    $fields['isreq'][0]  ='0';
    $fields['isemail'][0]='0';
    $fields['isclear'][0]='1';
    
    $fields['label'][1]  ='Email';
    $fields['type'][1]   ='textfield';
    $fields['isreq'][1]  ='0';
    $fields['isemail'][1]='1';
    
    $fields['label'][2]   ='Website|https://';
    $fields['type'][2]    ='textfield';
    $fields['isreq'][2]   ='0';
    $fields['isemail'][2] ='0';
    
    $fields['label'][3]='Job Title|Please pick a job title|-';
    
    // I need to pull a list of post titles in category '7' and pass them to the drop down select box
    // I don't know how to code this bit
    // 1) create an string of post titles using query_posts or WP-query???
    // 2) feed it to the field array ??
    
    $fields['type'][3]   ='selectbox';
    $fields['isreq'][3]  ='1';
    $fields['isemail'][3]='0';
    
    $fields['label'][4]   ='CV upload';
    $fields['type'][4]    ='upload';
    $fields['isreq'][4]   ='0';
    
    $fields['label'][5]   ='Demo upload';
    $fields['type'][5]    ='upload';
    $fields['isreq'][5]   ='0';
    
    $fields['label'][6]   ='Answer this question';
    $fields['type'][6]    ='verification';
    $fields['isreq'][6]   ='1';
    
    insert_custom_cform($fields,8);    //Call form #8 with new fields
    
    ?>

    I need some help pulling in the post titles from category id=7.

    Anyone?

Viewing 1 replies (of 1 total)
  • The topic ‘query_posts result into an array for contact form pull-down list’ is closed to new replies.