SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2002
    0 Post(s)
    0 Thread(s)

    accessing an array of inputs

    Hi, my question is regarding how to access an array of inputs that is generated on the fly as an array.

    For instance, I have information about books that can be accessed by an administrator in a catalogue. They can select a category and that will generate as many rows of data on each book as there are books in the category. The resultant form might look like this...

    <form action="none.php" method="post" name="form1" onsubmit="return validateForm(form1)">
    <!-- the book's ID -->
    <input type="hidden" name="book[0][0]" value="1">
    <!-- the book's name -->
    <input type="text" name="book[0][1]" value="whatever"><br>
    <!-- the book's author -->
    <input type="text" name="book[0][2]" value="whatever"><br>
    <!-- the book's ISDN -->
    <input type="text" name="book[0][3value="whatever"><br>
    <!-- the book's ID -->
    <input type="hidden" name="book[1][0]" value="2">
    <!-- the book's name -->
    <input type="text" name="book[1][1]" value="whatever"><br>
    <!-- the book's author -->
    <input type="text" name="book[1][2]" value="whatever"><br>
    <!-- the book's ISDN -->
    <input type="text" name="book[1][3]" value="whatever"><br>
    <!-- You get the idea! -->
    <input type="submit" name="goButton" value="Go">

    What I am wondering is how to access any of the values of the input named "book" for a JavaScript form validation.

    <script language="javascript">

    function validateForm(form)
    // this returns 'undefined'

    //this returns nothing at all and causes the function to fail
    return false;


    any ideas?

    thx in advance
    Last edited by grahowler; Jun 11, 2003 at 21:29.


Posting Permissions

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