SitePoint Sponsor

User Tag List

Page 3 of 5 FirstFirst 12345 LastLast
Results 51 to 75 of 112
  1. #51
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Can you help me with snippet of codes because I dont know how to further traverse to achieve the "a" value?

  2. #52
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Can you help me with snippet of codes because I dont know how to further traverse to achieve the "a" value?
    I am not in a situation to do that for you, but I can help you with any problems you may be facing.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #53
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Ok I can now traverse through specifically just the table and manage to get exact number of row and columns as below. Can help me how to put in the validation now?


    var table = document.getElementById("tblLayoutDetails");
    alert("Rows length : "+table.rows.length);
    for(var i=1;i<table.rows.length;i++){


    cells = table.rows[i].getElementsByTagName("td");
    alert("Cells length :"+cells.length);
    for (var i = 0; i < cells.length; i++) {


    }

    }

  4. #54
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Ok I can now traverse through specifically just the table and manage to get exact number of row and columns as below
    I thought you just needed to loop through the links in the form?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #55
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Yes but how to retstrict it using the column number is it? Or any other method?

  6. #56
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Yes but how to retstrict it using the column number is it?
    I don't understand. What is there to restrict?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #57
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Because you said to get only the links I dont know how to get via your method the only way I can think of is for (var i = 0; i < cells.length; i++) { get only the specific column related to links is that correct?

  8. #58
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    [QUOTE=newtomysql;4923031Because you said to get only the links I dont know how to get via your method[/QUOTE]

    Presume that the form is wrapped around the table that has the links.

    Step 1. Gain a reference to the form
    Step 2. Use getElementsByTagName to get all of the "a" tags that are inside of the form.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  9. #59
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    I dont get you how to get Step 2. because getElementsByTagName require the exact name right? I am stuck here dont know how to proceed with your idea?

  10. #60
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    [QUOTE=newtomysql;4923034]I dont get you how to get Step 2. because getElementsByTagName require the exact name right?[quote]

    It just requires the tag name. Do you know about HTML tag names, like div, or p, or a, or img? Those are tag names.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  11. #61
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Correct me here. So what is next run a for loop is it?
    Step 1.var form1= document.getElementById('form1');
    Step 2.var links = form1.getElementsByTagName("a");

  12. #62
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Correct me here. So what is next run a for loop is it?
    It is.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  13. #63
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Ok have now this. What to check next getValue is it?
    function validateForm()
    {
    var form1= document.getElementById('form1');
    var links = form1.getElementsByTagName("a");
    for (var i = 0; i < links.length; i++) {

    alert("I : "+i);
    }

  14. #64
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newtomysql View Post
    What to check next getValue is it?
    Well if you're lazy you can use innerHTML, but that's more expensive in terms of processing time. You should be fine instead just checking the nodeValue of the element itself.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  15. #65
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Must I do like this is it
    for (var i = 0; i < links.length; i++) {

    alert("I : "+i)i.firstChild.nodeValue);
    }
    ?

  16. #66
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Must I do like this is it?
    You're wanting to check if it's equal to a certain value, aren't you?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  17. #67
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    I am doing it like this but is not checking the value either.

    var form1= document.getElementById('form1');
    var links = form1.getElementsByTagName("a");
    for (var i = 0; i < links.length; i++) {

    if(i.firstChild.nodeValue=="Select")
    {
    alert("Did not select value:");
    }
    }

  18. #68
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    I am doing it like this but is not checking the value either.
    You are attempting to get the firstChild of i, which is a number. Can you see the problem there?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  19. #69
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    So what is the right method then? What does the first child reference to which number ?

  20. #70
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    So what is the right method then? What does the first child reference to which number ?
    The number should be used to retrieve one of the elements from the links array. It is from those elements that you can gain a reference to the firstChild
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  21. #71
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    So what is the right method to get the value of the "a" itself then? Thank you.

  22. #72
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newtomysql View Post
    So what is the right method to get the value of the "a" itself then? Thank you.
    Do you know how to use a for loop in order to loop through items of an array?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  23. #73
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    I am not too sure because from what I understand this is looping through all the "a" right? for (var i = 0; i < links.length; i++)? so what else array I need?

  24. #74
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    I am not too sure because from what I understand this is looping through all the "a" right?
    for (var i = 0; i < links.length; i++)
    No, that is not looping through all of the "a". What that does is to set the i variable to a number that starts at 0, and each time through the loop the number increases by one.

    You are supposed to use that number to retrieve the appropriate item from the array, that item in your case will then be one of the anchor links that you are wanting to work with.

    The following on JavaScript Array Basics might be of some help for you to further your understanding of them.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  25. #75
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    873
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    I know about the arrays. But what I do not know which is the array and what this array consists of and what value can I get from this array? Saw an example of this getElementsByTagName("a")[0].href' so must I do something like 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
  •