SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    text box array problems.

    Hi.

    I am trying to loop through an array of text boxes to do some basic validation and I'm falling at the first hurdle.

    The array looks like this>>>

    [delegateTitle] => Array
    (
    [0] =>
    [1] =>
    )

    [delegateEmail] => Array
    (
    [0] =>
    [1] =>
    )

    [delegateFirstName] => Array
    (
    [0] =>
    [1] =>
    )

    [delegateRequests] => Array
    (
    [0] =>
    [1] =>
    )

    [delegateLastName] => Array
    (
    [0] =>
    [1] =>
    )

    [delegateJobTitle] => Array
    (
    [0] =>
    [1] =>
    )
    and my code looks like this....

    Code JavaScript:
    function checkTheDelegates()
    	{
     
    		var numberOfDelegates = document.bookCourse.numberOfDelegates.value;
    		for (i = 0; i <numberOfDelegates; i++)
    			{
    				var delegateTitle = document.bookCourse.delegateTitle[i].value;
    				var delegateFirstName = document.bookCourse.delegateFirstName[i].value;
    				var delegateLastName = document.bookCourse.delegateLastName[i].value;
    				var delegateEmail = document.bookCourse.delegateEmail[i].value;
    				var delegateRequests = document.bookCourse.delegateRequests[i].value;
    				var delegateJobTitle = document.bookCourse.delegateJobTitle[i].value;
     
     
    			}
     
    	}

    I cant even begin to access the values of the text boxes at the minute.. What am I doing wrong....

  2. #2
    SitePoint Evangelist TommiChi's Avatar
    Join Date
    Oct 2008
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The very first problem I can spot is a syntax error in your "for" statement. There should be a space after the "<" character.


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
  •