#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2004
    Location
    Boston, MA USA
    Posts
    583
    Rep Power
    51

    Accordion Sections without Submitting Forms


    Hi:

    I am trying to create an "accordion" section on an input form to show and hide various portions of the page according to what the user needs to see.

    I have been using the following as a guide:
    https://www.w3schools.com/howto/tryi...w_js_accordion

    The problem I am having is that the accordion buttons submit the form in order to refresh the display. However, at the time the user might want to show/hide sections, the form is not complete and submitting it prematurely causes problems.

    Can anyone suggest a correction that will dynamically show/hide page sections without submitting the page?

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2016
    Posts
    143
    Rep Power
    66
    This is because a button inside a form submits the form.

    Change the <button>...</button> tags to <div>...</div> tags.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2004
    Location
    Boston, MA USA
    Posts
    583
    Rep Power
    51
    Originally Posted by DSmabismad
    This is because a button inside a form submits the form.

    Change the <button>...</button> tags to <div>...</div> tags.
    Oh... of course!

    Thanks.

IMN logo majestic logo threadwatch logo seochat tools logo