Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    824
    Thanks
    93
    Thanked 18 Times in 18 Posts

    HTML form using arrays and keys

    I'm not sure if this is more HTML or Javascript so sorry if this should be in HTML.

    I need to build a form with inputs named like

    name[0][first]
    name[0][second]
    name[0][third]
    name[1][first]
    name[1][second]
    name[1][third]

    I have a form labeled as such but when I print the results to the console using

    Code:
    $('.input').each(function(k,v){
        console.log(k+$(v).val());
    });
    k is just 0,1,2,3,4 etc, and I dont get the first, second, third part anywhere either.

    Is this at all possible to do with javascript/jquery alone?

    I need it this way because I need to use the data this way

    Code:
    while(someLoop) {
    functionforfirst(values['first']);
    functionforsecond(values['second']);
    functionforthird(values['third']);
    I need to loop through each set and run functions of the different bits of data. If there is a easier way to do this compared to what I'm doing I'm all ears .

    EDIT: Nevermind, my boss changed the brief again and I no longer need to take this route.
    Last edited by tomharto; 05-02-2013 at 02:23 PM. Reason: Not needed anymore


 

Posting Permissions

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