SitePoint Sponsor

User Tag List

Page 2 of 5 FirstFirst 12345 LastLast
Results 26 to 50 of 112
  1. #26
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    But can my codes change the select word the val based on the checkbox selected. Thank you.
    The child can pass whatever information is needed to the parent, and the parent can make whatever changes you need to make.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  2. #27
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    I manage to solve all the relevant problem. Now I got a next problem where I need to post this form and I must make sure now the all the select are replace with the tyre serial and also how am I going to capture the post value as there all will be dynamic? Any idea?

  3. #28
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    I manage to solve all the relevant problem. Now I got a next problem where I need to post this form and I must make sure now the all the select are replace with the tyre serial and also how am I going to capture the post value as there all will be dynamic? Any idea?
    You could use form inputs to store the values, so that they are then submitted with the form. If you don't want them to be displayed, use hidden inputs.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #29
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    The problem each time you pick a different layout you will get different number of tyres. So how to capture in the php post? Because I cant put like this $RI1L=$_POST['RI1L']; because each has different number of tyres.

  5. #30
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    The problem each time you pick a different layout you will get different number of tyres. So how to capture in the php post? Because I cant put like this $RI1L=$_POST['RI1L']; because each has different number of tyres.
    You could give the form field a name such as "tyre['RI1L']" so that PHP just needs to get the submitted tyre array, and loop through the keys in that array,
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  6. #31
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    I am not quite clear with your solution. Say I first I got only 4 tyre so I have row1 tyre['F1L'],tyre['F1R'] , row2 tyre['R1L'],tyre['R1R']. Second one I got row1 tyre['F1L'],tyre['F1R'] , row2 tyre['R1L'],tyre['R1R'], row3 tyre['R2L'],tyre['R2R']. So how on the php I should capture it based on this two example? In php I can have this $tyre= (array) $_POST[tyre]; right.

  7. #32
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    So how on the php I should capture it based on this two example? In php I can have this $tyre= (array) $_POST[tyre]; right.
    You don't need to cast it as an array because the field names already ensures that it is an array.

    You can then use standard PHP techniques to process the array, for example:

    Code php:
    foreach ($tyre as $wheel => $type) {
        ...
    }

    But that's diverging quite strongly from the intention of this forum, to help people with JavaScript coding.
    The people in the PHP forum will be better placed to give PHP-based solutions for you.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  8. #33
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Ok I will post it over on php. Another question on javascript side. How am I going to validate this form based on each different layout where each of the select must have tyreID and also must be different?

  9. #34
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    Ok I will post it over on php. Another question on javascript side. How am I going to validate this form based on each different layout where each of the select must have tyreID and also must be different?
    You can attach a function to the onsubmit event of the form, which could check that you have no links left in there, and other conditions that must be met.

    Failure to meet any condition can result in false being returned from the function, which cancels the submit event.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  10. #35
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    IS it that is must be something like this.

    var elem = document.getElementById('frmMain').elements;
    for(var i = 0; i < elem.length; i++)
    {

    }

  11. #36
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    IS it that is must be something like this.
    Nope, it's where you assign to the onsubmit event of the form a function that performs the validation checks that you require.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  12. #37
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Yes first I have this line to make the form
    <form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="form1" id=form1 onSubmit="return validateForm();">. I would like to ask you opinion if it is a table where to best put the form element in a tr or td? Then next I have my function as below for the onSubmit.

    function validateForm()
    {
    var elem = document.getElementById('form1').elements;
    for(var i = 0; i < elem.length; i++)
    {

    }

    }

  13. #38
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    Yes first I have this line to make the form
    <form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="form1" id=form1 onSubmit="return validateForm();">. I would like to ask you opinion if it is a table where to best put the form element in a tr or td? Then next I have my function as below for the onSubmit.
    Your requirements are quite peculiar from the standard form validation techniques.

    I presume that the first thing you'll need to check is if any of the links to select a tyre are still there. If there are any, the form shouldn't be submitted, right?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  14. #39
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Yes you are right if it is still select dont allow is to be submitted. So where to put extra control then?

  15. #40
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    Yes you are right if it is still select dont allow is to be submitted. So where to put extra control then?
    If you replace the link text with the choice that they made, then one of the checks could be to get a collection of links from the appropriate section. If any of them have the select text, the form should not yet be submitted.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  16. #41
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Yes I am replacing the "Select" word with the tyre serial which they have selected. I am stuck is how to do the checking on who have the "Select" text? Must I do a for loop as I proposed earlier? Thank you.

  17. #42
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    Yes I am replacing the "Select" word with the tyre serial which they have selected. I am stuck is how to do the checking on who have the "Select" text? Must I do a for loop as I proposed earlier? Thank you.
    A loop of the anchor elements would do, where you check the nodeValue for the "Select" text.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  18. #43
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    I know this loop is to get all the elements. What do you mean by anchor element and how to go about that?

    var elem = document.getElementById('form1').elements;
    for(var i = 0; i < elem.length; i++)
    {

    }

  19. #44
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    I know this loop is to get all the elements. What do you mean by anchor element and how to go about that?
    If you have a reference to the form, you can use the .getElementsByTagName() method to retrieve all of the elements within the form, of a given tag name.

    For example:

    var links = form.getElementsByTagName('a');
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  20. #45
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    The problem each time I change the drop down list value the tag names also will be different so how to cater for that? My names will be not fixed and according to the layouts.

  21. #46
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    The problem each time I change the drop down list value the tag names also will be different so how to cater for that? My names will be not fixed and according to the layouts.
    You retrieve them during the validation process of the form, so that the current state of the form is what gets processed.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  22. #47
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Based on the link you gave I am trying to modify now. The table name is fine. But how to loop all the tr because in this case I only get one 'tr' right? So after the 'tr' I must get the 'td' right?

    var table = document.getElementById("tblLayoutDetails");

    var cells = table.getElementsByTagName("tr");

    for (var i = 0; i < cells.length; i++) {
    var status = cells[i].getAttribute("data-status");

    if ( status == "open" ) {

    // grab the data
    }
    }

  23. #48
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Based on the link you gave I am trying to modify now. The table name is fine. But
    The code from that documentation site only shows an example of how the getElementsByTagName method can be used. However, it's not a template of the code that you need to write to solve your problem.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  24. #49
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    874
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear Paul,
    Any hints how to start and move or should I use the traditional way of looping through everything like this var elem = document.getElementById('form1').elements;
    for(var i = 0; i < elem.length; i++)?

  25. #50
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newtomysql View Post
    Dear Paul,
    Any hints how to start and move or should I use the traditional way of looping through everything like this var elem = document.getElementById('form1').elements;
    for(var i = 0; i < elem.length; i++)?
    That will only get you the form controls - like textarea, input or select - it won't do anything about helping you to retrieve the links from within the form.

    You need to gain a reference to the form, and then use that form reference to get the links by their tag name, that being "a".
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •