dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Wildcard in document.form

  1. #1
    Join Date
    Sep 2009
    Posts
    4

    Wildcard in document.form

    Hello everybody,

    I wonder if someone can help. I have a dynamically created form. Users add rows by clicking 'add row'.

    On each row there is a field which represents a date. On the first row it is named "sd[0]", on the second "sd[1]" on the third "sd[3]" and so on.

    I also have a master date, called simply "sd". I have an onclick event on this. When the value of this is changed I want all of the other dates also to change.

    I have tried the following:

    function updateDates(x,y)
    {
    document.form["sd["+*+"]"].value=x;
    }

    Where * is a wildcard. This doesn't work. Can anybody suggest a solution? It will be very appreciated.

    I imagine a loop will be needed if wildcards aren't an option, however I just can't get my head round it.

    N

  2. #2
    Join Date
    Sep 2009
    Posts
    4

    a solution that doesn't work

    I tried the following. It doesn't work but I think it's a move in the right direction. Any ideas?

    function updateDates(x,y)
    {
    var tbody=document.getElementById(tbodyID);
    var rowCount=tbody.rows.length;
    i=0;
    while (i<=rowCount)
    {
    document.form["sd["+i+"]"].value=x;
    i++;
    }
    }

  3. #3
    Join Date
    Aug 2007
    Posts
    3,767
    All of them will probably be or should be in a container element. Loop through the inputs in that container element and set the value to whatever you want.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles