SitePoint Sponsor

User Tag List

Page 4 of 13 FirstFirst 12345678 ... LastLast
Results 76 to 100 of 310
  1. #76
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    I think you need to take another look at the selectors.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  2. #77
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Need your help a bit ok correct me here $("table.dynatable tr:first") will this give me the first row?

  3. #78
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    Need your help a bit ok correct me here $("table.dynatable tr:first") will this give me the first row?
    That will give you the first row of the table, which might be in the thead section or in the tbody section, depending on the table that you have.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #79
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    So if like this $("table.dynatable tbody tr:first td:first") will this give the tbody first row and first column?

  5. #80
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    So if like this $("table.dynatable tbody tr:first td:first") will this give the tbody first row and first column?
    Yes.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  6. #81
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Will this give the first row and second column $("table.dynatable tbody tr:first td:nth-child(2)") ?

  7. #82
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Ok I checked read this works fine exactly for the first row and second column. So how to enforce idea your said earlier.
    $("table.dynatable tbody tr:first td:nth-child(2)").change( function()
    {
    alert("On change first locationFrom Column");
    }
    );

  8. #83
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    When the select field changes (you might want to use the actual select element for the change event), use its new value as the basis by which to set the other select fields that should have the same value.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  9. #84
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    I tried to capture the selected value this way $("table.dynatable tbody tr:first td:nth-child(2)").val() but I get nothing. Can you see what is my mistake?

    Quote Originally Posted by paul_wilkins View Post
    When the select field changes (you might want to use the actual select element for the change event), use its new value as the basis by which to set the other select fields that should have the same value.

  10. #85
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    I tried to capture the selected value this way $("table.dynatable tbody tr:first td:nth-child(2)").val() but I get nothing. Can you see what is my mistake?
    The td element has no value attribute.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  11. #86
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    So how to capture the value and put on the locationTo column then?

  12. #87
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    So how to capture the value and put on the locationTo column then?
    Select the select box that's inside the td element?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  13. #88
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    I tried this it works $('table.dynatable tbody tr:first td:nth-child(2) select[name="locationFrom[]"]').val()). But I am confuse why $("table.dynatable tbody tr:first td:nth-child(2)").change( function() it can work without putting the select name into it?

  14. #89
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    I tried this it works $('table.dynatable tbody tr:first td:nth-child(2) select[name="locationFrom[]"]').val()).
    You could have got away with just select instead of select[name="locationFrom[]"] because there's only the one select element inside the td.

    Quote Originally Posted by newtomysql View Post
    But I am confuse why $("table.dynatable tbody tr:first td:nth-child(2)").change( function() it can work without putting the select name into it?
    When an event is triggered, it works its way down through the DOM to the element that triggered the event. That's the capture phase. The bubble phase is where the event then bubbles back up from the element that triggered it up through the DOM, which is the phase that most of us use.

    Full details can be found at this event order page, but basically, a parent element can normally access events that happen to any of their children, and typically we access the event during the bubbling phase.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  15. #90
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    For the second parth will this work.
    $("table.dynatable tbody tr:first td:nth-child(4) select").selected=$("table.dynatable tbody tr:first td:nth-child(2) select").val();

  16. #91
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    For the second parth will this work.
    $("table.dynatable tbody tr:first td:nth-child(4) select").selected=$("table.dynatable tbody tr:first td:nth-child(2) select").val();
    You would want to use this instead:
    $(...).val($(...).val())

    Oh, and is :nth-child(4) the last td of that row?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  17. #92
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Here I really dont know what is it $(...).val($(...).val()) ? Can you give more details. The nth-child(4) is the second last column where I wanted the earlier from nth-child(2) to get into?

  18. #93
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    Here I really dont know what is it $(...).val($(...).val()) ? Can you give more details. The nth-child(4) is the second last column where I wanted the earlier from nth-child(2) to get into?
    The ... is just eliding parts for clarity.

    Before you posted this suggested code:
    $("table.dynatable tbody tr:first td:nth-child(4) select").selected=$("table.dynatable tbody tr:first td:nth-child(2) select").val();

    which for the sake of discussion, can be reduced to:
    $(...).selected=$(...).val();

    My suggestion is to use the following structure instead, to assign the appropriate select value.
    $(...).val($(...).val());
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  19. #94
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Great it works. The problem when I select the first one with empty value it does not the same for the 4th child. So if I am not mistaken I must also do another on change for the 4th child too right to keep things consistent right?

  20. #95
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Great it works. The problem when I select the first one with empty value it does not the same for the 4th child. So if I am not mistaken I must also do another on change for the 4th child too right to keep things consistent right?
    Right.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  21. #96
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    One problem you have not told me how to solve the if on change select the first one that is "-Select Location From-" for the second column is doe not change for the 4th column.

  22. #97
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Do each of those options have the same value?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  23. #98
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Yes for now each is same. But if different how to cater then?

  24. #99
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Yes for now each is same. But if different how to cater then?
    Consider the situation. What purpose could there be to match up two different select boxes when they have different options. What is actually being matched? It doesn't sound like a common scenario.

    In the off-chance that you require something like that though, you can resort to the selectedIndex property of the select box itself. But, that's a last resort that gets messier to implement than the easier to understand value paradigm that we currently have.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  25. #100
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    So in this current case both are the same source. So I just want to make sure the selected index of the second column and fourth column are same. Beside that now for the second row and so on how can I validate on submit that the 2nd column and 4th column is not the same.


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
  •