WordPress.org

Ready to get started?Download WordPress

Forums

Need Category descriptions from drop-down selection. (1 post)

  1. Jeremy Plack
    Member
    Posted 2 years ago #

    I have a form that puts post categories in a dropdown select menu, using the TDO Mini-forms plugin, users create a draft post via front-end form. I want to get the description for selected category on selection and display it below the selection menu. via an asynchronous event?

    here is the relevant form section:
    <!-- categories start -->
    <fieldset>
    <?php $defcat = 1; if(isset($post_args['categories'])) { $defcat = $post_args['categories']; } ?>
    Select a category:
    <select ' id='cat' name='categories' class='tdomf_categories' size='1' onchange="displaydesc()">
    <option id="1" value="1"<?php if( (is_array($defcat) && in_array(1, $defcat))
    || ( 1 == $defcat ) ) { echo ' selected="selected" '; } ?>
    >Uncategorized</option>
    <option id="2" value="4"<?php if( (is_array($defcat) && in_array(4, $defcat))
    || ( 4 == $defcat ) ) { echo ' selected="selected" '; } ?>
    >Web Design/Development</option>
    </select>
    </fieldset>
    <p>Description</p><span id="foo"></span>
    <script src="http://idealproject.us/postjobformcats.js"></script>

    and the JS (so far):
    function displaydesc() {
    document.getElementById("foo").innerHTML="Here goes the category description";
    }

Topic Closed

This topic has been closed to new replies.

About this Topic