SitePoint Sponsor

User Tag List

Page 7 of 8 FirstFirst ... 345678 LastLast
Results 151 to 175 of 184
  1. #151
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    Updated accordingly but still the same problem.
    Correction. Now standard-based web browsers are experiencing the same problem that IE is having.

    Now we move on to a solution to the same problem.

    What is the problem? After the page is loaded, the dynatable has two tbody elements. Because it has two tbody elements, a row gets added to each one.

    It is not appropriate to add the row to only the first tbody element that's found. While that curing the symptom, it doesn't do anything about the cause of the problem itself.

    So, why is the extra tbody being added?

    The cause of the problem is staring us right in the face.
    Look at your <tbody> tags and you will see the cause of the problem.

    Code:
    <table class="dynatable"> 
        <thead> 
            ...
        </thead> 
        <tbody> 
            <tr class="prototype"> 
                <td><input type="text" name="id[]" value="0" /></td> 
                <td><input type="text" name="classification[]" /></td> 
                <td><input type="text" name="start[]" value="0" readonly /></td> 
                <td><input type="text" name="end[]" /></td> 
                <td><button class="remove">Remove</button></td> 
            </tr> 
        <tbody> 
    </table>
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  2. #152
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    I notice only one tbody not two of it right. So why is this the problem?

  3. #153
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    I notice only one tbody not two of it right. So why is this the problem?
    They're both opening tags, so the web browser tried to interpret that as two completely different tbody sections.

    The second one should be a closing tag instead.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #154
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Ok it works fine. Then I tried the remove first it was just the "tr" then I modified but when I press the remove button the whole grid is gone $(this).parents("table.dynatable").remove();. Secondly I have to put the colspan a big number like 80 then only you can see my Duration of Scheme* and Duration of Probation* and the relevant combo box are neatby if not they become far apart. Is this the solution or any other method for it ?

    <tr>
    <td colspan="80">
    <table class="dynatable">

  5. #155
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    Ok it works fine. Then I tried the remove first it was just the "tr" then I modified but when I press the remove button the whole grid is gone
    What was it before you changed it?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  6. #156
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Before this it was like this $(this).parents("tr").remove();. So when I press the remove button every thing gets remove meaning even the combo box and just left the one title at the top that is "Create Scheme by parameterise the following values:- "

  7. #157
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    O instead of parents("tr") you'll be wanting to instead use closest('tr')
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  8. #158
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Great it works how to differentiate between the parent and closest. Another thing I have to put the colspan a big number like 80 then only you can see my Duration of Scheme* and Duration of Probation* and the relevant combo box are neatby if not they become far apart. Is this the solution or any other method for it ?

    <tr>
    <td colspan="80">
    <table class="dynatable">

  9. #159
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    Great it works how to differentiate between the parent and closest. Another thing I have to put the colspan a big number like 80 then only you can see my Duration of Scheme* and Duration of Probation* and the relevant combo box are neatby if not they become far apart. Is this the solution or any other method for it ?
    There are none that javascript is appropriate for.

    The good people in the CSS forum should have an appropriate solution for that though.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  10. #160
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Ok I will post it to the CSS people the alignment problem.I would like you to visit this site http://183.78.169.54/v3/dynamicrow.php. If you notice the grid is on default fill with 2 values from the db. I run a for loop to fill it. The codes is something like below. The problem now once this data is fill my Add button cannot add the row and even remove button does not work. I suspect the Id is not synchrous with the one from the database count?

    <tbody>
    <?php
    $count = 1;
    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
    ?>
    <tr class="prototype">
    <td><input type="text" name="id[<?=$count;?>]" value="0" /></td>
    <td><input type="text" name="name[<?=$count;?>]" value=<?=$row['nameOfFormerEmployee'];?> /></td>
    <td><input type="text" name="durationOfEmployment[<?=$count;?>]" value=<?=$row['durationOfEmployment'];?> /></td>
    <td><textarea rows=2 cols=15 name="reasonLeaving[<?=$count;?>]" /><?=$row['reasonForLeaving'];?></textarea></td>
    <td><textarea rows=2 cols=15 name="previousRecords[<?=$count;?>]" /><?=$row['previousRecords'];?></textarea></td>
    <td><button class="remove">Remove</button>
    </tr>
    <?
    $count++;
    }
    ?>

    </tbody>

  11. #161
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Add button cannot add the row and even remove button does not work. I suspect the Id is not synchrous with the one from the database count?
    ID has nothing to do with the problem.

    Go and read post #90 which gives the solution to your current problem.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  12. #162
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    So meaning that once I have read the value from the db I have to create a special function in jquery to validate the field created based on the database is it?

  13. #163
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    So meaning that once I have read the value from the db I have to create a special function in jquery to validate the field created based on the database is it?
    No, that's not what was meant. I'll quote the salient parts from post #90 just so there is no confusion about this.

    The error is the validator's way of telling you that you're trying to access a field that has not yet been set up for validation.
    You need to run the validate() method on the form, before you can access the rules for a field in the form.
    Which is why you should ...

    do it as the first statement of the setupFormValidation function.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  14. #164
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Is it that I need call a jquery function once I am done populating the php values? Is it possible to call a jquery function via php codes? So when I call I need to pass the total number of data so far is it?

  15. #165
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    Is it that I need call a jquery function once I am done populating the php values? Is it possible to call a jquery function via php codes? So when I call I need to pass the total number of data so far is it?
    Whenever you add or remove form fields, you need to rerun the validate() method on the form. That will add special glue to the added fields, and it will prevent the removed fields from killing things.

    After that validate() method has been run, you can then go on with adding validation methods to different fields.

    That is why you should do it as the first statement of the setupFormValidation function.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  16. #166
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    It works now. I have added as this. The problem now each time I press Add two rows get added and together with the contents from the previous grid?


    function setupFormValidation(form) {
    $(form).validate().resetForm();

  17. #167
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Are both of the rows prototypes to be added? No? Then remove the class "prototype" from one of them.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  18. #168
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Ok done accordingly. Now if you notice the problem is the ID the first two automatically becomes 0 so when I submit I am going to have problem loosing data. How to settle on this?

  19. #169
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Ok done accordingly. Now if you notice the problem is the ID the first two automatically becomes 0 so when I submit I am going to have problem loosing data. How to settle on this?
    Edit the attributes of the HTML elements?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  20. #170
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    I might be confusing you. Ok say for example in this case I have read 2 values from the db. So the next value when I add a new row should be 3 etc. How to control that ? Thank you.

  21. #171
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Currently it's line 96 of the html page that determines where that starts from.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  22. #172
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Yes saw that how once I have populate from the db the number of rows to update this value var id = 0; which is in the jquery script?

  23. #173
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Could you write the number of rows retrieved from the db?

    This is PHP and may not be exactly what you require, but it should be close.

    Code php:
    $idCounter = mysql_num_rows($result);

    Then after jQuery is loaded:

    Code html4strict:
    <script type="text/javascript">
    $(document).data('idCounter', <?php echo $isCounter; ?>);
    </script>

    And in the script file:

    Code javascript:
    $id = $(document).data('idCounter') || 0;
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  24. #174
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Thank you looks like it works well now I will do some testing and get back to you.

  25. #175
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    I have new page here http://183.78.169.54/v3/addTab.php . Then can you press the Driver Employment and add just two rows with out any data and press the add button. You will notice it will take you to another tab which is the Driver Details and below that the rows appear there two. So my question why it appear there and also all my fields will have the error "This field is required". The problem here is that for my two other tab (Driver Details and Licenses) I am using normal java script for the checking then for the Driver Employment I am using your Jquery script. How to solve this?


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
  •