SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2011
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Combo Form Field Help

    Hello,
    I am creating an admin backend for a site.
    This admin backend will add instructors.
    I need to have the ability to assign the instructors to several categories. So far easY? Multiple select field.

    Here is where i am stuck.
    I need a nice way of adding new categories on the fly without refreshing entire page.
    Anyone know of any ajax, jqueryui or tutorial on how to accomplish this using PHP/MYSQL values that populate the categories field?

    Thanks

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,747
    Mentioned
    65 Post(s)
    Tagged
    0 Thread(s)
    So you're looking at this from the Admin user's POV.

    The user is looking at an Instructor Edit page.

    You have a multiple select field (box).

    You need to add a new item to the select field box. So you need a separate form/lone input box with a button next to it that says "Add Category".
    Add Category button is wired to javascript that kicks off an AJAX request to the server.
    Server takes in Category Name, spits out Category ID and Name again.
    AJAX handler processes return, appends element to the list.

    So... ignoring the fact that this requires your user to have javascript enabled, what part of the three are you having difficulty with?

    1: Forming the AJAX request
    2: The PHP to receive the AJAX request and return the reponse
    3: The line of jQuery needed to add the category to the box

    Show us what you've done, and we can try and point you in the right direction.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2011
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Starlion.
    Thanks for your response.
    Im having an issue with all 3.
    I am not good with AJAX, so I was looking to see if anyone knew of a solution that exists with documentation on how to install.

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,747
    Mentioned
    65 Post(s)
    Tagged
    0 Thread(s)
    Basic AJAX example: http://www.w3schools.com/ajax/tryit....=tryajax_first
    Basic AJAX tutorial: http://www.w3schools.com/ajax/default.asp
    (This covers #1; #2 you should be able to do)
    jQuery to append a category to a multi-select: $("#catSelect").append('<option value="1">My option</option>');
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •