Need general purpose javascript code to hide/display entry fields on a form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pat Scott

    #1

    Need general purpose javascript code to hide/display entry fields on a form

    I am looking for a general purpose javascript snippet that enables me to
    <div> or <span> HTML to make portions of the form be hidden and then appear.
    The form contains about 12 sections and some sections can contain
    subsections. When the user clicks on a checkbox, I want previously hidden
    text boxes, radio buttons, text, drop down menus, and additional checkboxes
    to appear. In some cases, clicking on a checkbox in a section can cause
    additional previously hidden text boxes, radio buttons, text, drop down
    menus, and additional checkboxes to appear.

    Within each section, a list of individual names is displayed with an initial
    checkbox beside each name being displayed. Clicking the checkbox beside a
    name is what triggers the hidden info to be displayed. The server side
    application is written in php and the field names are assigned using
    brackets as the array is created. As an example the HTML checkbox beside
    the first name <input type='checkbox' name='sect1cust name[1]' value'First
    Name'> The HTML for the next name woud be exactly the same except the name
    field would be defined as name='sect1cust name[2]'. All of the other input
    buttons, boxes, menus, and text would use the same naming conventions so
    that the server side module can correctly process the data.

    I am hoping to keep this as generic as possible so that we can add, change,
    and/or delete entire sections simply by creating the appropriate HTML and
    surrounding it with the correct <div> or <span>. I understand that there
    may need to be some javascript wrapped around the checkboxes.

    If you know of , or have, or can develop the code, please send particulars
    to jscott4272 at comcast dot net. If there are any costs associated with
    the code, just let me know what they are. If you have any questions or need
    additional information, please email them to me.

    Pat Scott




  • Dennis Marks

    #2
    Re: Need general purpose javascript code to hide/display entry fields on a form

    In article <nYKdndJDRIs41i zdRVn-jg@comcast.com> , Pat Scott
    <badmailaddr@ao l.com> wrote:
    [color=blue]
    > I am looking for a general purpose javascript snippet that enables me to
    > <div> or <span> HTML to make portions of the form be hidden and then appear.
    > The form contains about 12 sections and some sections can contain
    > subsections. When the user clicks on a checkbox, I want previously hidden
    > text boxes, radio buttons, text, drop down menus, and additional checkboxes
    > to appear. In some cases, clicking on a checkbox in a section can cause
    > additional previously hidden text boxes, radio buttons, text, drop down
    > menus, and additional checkboxes to appear.
    >
    > Within each section, a list of individual names is displayed with an initial
    > checkbox beside each name being displayed. Clicking the checkbox beside a
    > name is what triggers the hidden info to be displayed. The server side
    > application is written in php and the field names are assigned using
    > brackets as the array is created. As an example the HTML checkbox beside
    > the first name <input type='checkbox' name='sect1cust name[1]' value'First
    > Name'> The HTML for the next name woud be exactly the same except the name
    > field would be defined as name='sect1cust name[2]'. All of the other input
    > buttons, boxes, menus, and text would use the same naming conventions so
    > that the server side module can correctly process the data.
    >
    > I am hoping to keep this as generic as possible so that we can add, change,
    > and/or delete entire sections simply by creating the appropriate HTML and
    > surrounding it with the correct <div> or <span>. I understand that there
    > may need to be some javascript wrapped around the checkboxes.
    >
    > If you know of , or have, or can develop the code, please send particulars
    > to jscott4272 at comcast dot net. If there are any costs associated with
    > the code, just let me know what they are. If you have any questions or need
    > additional information, please email them to me.
    >
    > Pat Scott
    >
    >
    >
    >[/color]
    In styles have "visibility : hidden" if you want the division initially
    hidden.

    In the following function theMenu is the division id.
    theAction is either "visible" or "hidden".

    function showMenu(theMen u, theAction) {
    if (document.getEl ementById)
    {document.getEl ementById(theMe nu).style.visib ility = theAction;}
    else if (document.layer s) {document[theMenu].visibility = theAction;}
    else {document[theMenu].style.visibili ty = theAction;}
    }

    It works for me but I give no guarantees.

    --
    Dennis Marks

    To reply change none to dcsi.


    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

    Comment

    • Robert

      #3
      Re: Need general purpose javascript code to hide/display entry fields on a form

      [color=blue]
      > If you know of , or have, or can develop the code, please send particulars
      > to jscott4272 at comcast dot net.[/color]

      This post in google will do some of what you want. Although, I think
      you want to use a little bit more sophisticated techniques.


      lm=c6bb75ff.040 5071926.3e45f8c %40posting.goog le.com&rnum=1

      Re: JS: two sets of required fields in one form and see the post with
      "I have made a few revisions to the file."

      Robert

      Comment

      Working...