Results 1 to 3 of 3
  1. #1
    Rick is offline Member
    Join Date
    Jun 2011
    Posts
    1
    Rep Power
    0

    Default Help please, with forms

    New to Java here, any help would be really nice guys.

    I have two buttons to hide and show a form using java. You press + to add another group of table rows. <tbody>.

    The problem I have is that when you press (-) to remove the second group, it only hides the group. What I need to do is to hide and also reset (if any) values on the fields in that <tbody>.
    Now it only hides the field "amount" and if there's anything in there it would still add to the total amount later on.

    Thanks,



    <script type="text/javascript">

    function hide(obj) {


    var el = document.getElementById(obj);

    if ( el.style.display != 'none' ) {

    el.style.display = 'none';


    }


    function show(obj) {


    var el = document.getElementById(obj);

    el.style.display = '';



    }

    </script>

    </head>

    <body>


    <table class="formTable">
    <tr>
    <td colspan="3">
    <div class="subheader">Please enter your Billing details below</div>
    </td>
    </tr>

    <tbody id="1">
    <tr>
    <td class="fieldLabel">&nbsp;</td>
    <td colspan="2" class="fieldData">&nbsp;</td>
    </tr>
    <tr>
    <td class="fieldLabel"><span class="subheader">Child details</span></td>
    <td colspan="2" class="fieldData">&nbsp;</td>
    </tr>
    <tr>
    <td class="fieldLabel"><span class="warning">*</span>Child's Account Code: </td>
    <td colspan="2" class="fieldData"><input name="Child1Account" type="text" maxlength="20" value="<? echo htmlentities($strChild1Account) ?>" style="width: 200px;"></td>
    </tr>
    <tr>
    <td class="fieldLabel"><span class="warning">*</span>Forename:</td>
    <td colspan="2" class="fieldData"><input name="Child1Firstnames" type="text" maxlength="20" value="<? echo htmlentities($strChild1Firstnames) ?>" style="width: 200px;"></td>
    </tr>
    <tr>
    <td class="fieldLabel"><span class="warning">*</span>Surname:</td>
    <td colspan="2" class="fieldData"><input name="Child1Surname" type="text" maxlength="20" value="<? echo htmlentities($strChild1Surname) ?>" style="width: 200px;"></td>
    </tr>
    <tr>
    <td class="fieldLabel"><span class="warning">*</span>Amount: </td>
    <td colspan="2" class="fieldData"><input name="Child1Amount" type="text" maxlength="20" value="<? echo htmlentities($strChild1Amount) ?>" style="width: 200px;"></td>

    </tr>
    </tbody>
    <tr>
    <td class="fieldLabel">&nbsp;</td>
    <td width="20"><input name="show2" type="button" value="+ child2" onClick="show('2')"></td>

    </tr>



    <tbody id="2" style="display: none;">
    <tr>
    <td class="fieldLabel"><span class="subheader">Child 2 details </span></td>
    <td colspan="2" class="fieldData">&nbsp;</td>
    </tr>
    <tr>
    <td class="fieldLabel"><span class="warning">*</span>Child's Account Code: </td>
    <td colspan="2" class="fieldData"><input name="Child2Account" type="text" maxlength="20" value="<? echo htmlentities($strChild2Account) ?>" style="width: 200px;"></td>
    </tr>
    <tr>
    <td class="fieldLabel"><span class="warning">*</span>Forename:</td>
    <td colspan="2" class="fieldData"><input name="Child2Firstnames" type="text" maxlength="20" value="<? echo htmlentities($strChild2Firstnames) ?>" style="width: 200px;"></td>
    </tr>
    <tr>
    <td class="fieldLabel"><span class="warning">*</span>Surname:</td>
    <td colspan="2" class="fieldData"><input name="Child2Surname" type="text" maxlength="20" value="<? echo htmlentities($strChild2Surname) ?>" style="width: 200px;"></td>
    </tr>
    <tr>
    <td class="fieldLabel"><span class="warning">*</span>Amount: </td>
    <td colspan="2" class="fieldData"><input name="Child2Amount" type="text" maxlength="20" value="<? echo htmlentities($strChild2Amount) ?>" style="width: 200px;"></td>
    </tr>

    <tr>
    <td class="fieldLabel">&nbsp;</td>
    <td><input name="hide2" type="button" value="- child2" onClick="hide('2')"></td>
    </tr></tbody>
    <tr>
    <td class="fieldLabel"><span class="subheader">Your details</span></td>
    <td colspan="2" class="fieldData">&nbsp;</td>
    </tr>
    <tr>
    </table>

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    You need to google for a JavaScript forum - this one's for Java (a different language).

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,237
    Rep Power
    19

Similar Threads

  1. JSP Forms
    By samcarlsruh in forum New To Java
    Replies: 1
    Last Post: 05-28-2011, 03:57 PM
  2. Switch between forms.
    By OMFGITSROHIT in forum AWT / Swing
    Replies: 9
    Last Post: 03-13-2010, 07:47 PM
  3. Forms in MultiPageEditorPart
    By darie20 in forum SWT / JFace
    Replies: 0
    Last Post: 02-01-2010, 12:22 PM
  4. Replies: 2
    Last Post: 04-28-2008, 10:56 AM
  5. Forms in jsp
    By bbq in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-05-2007, 04:28 AM

Posting Permissions

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