SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot keira's Avatar
    Join Date
    Aug 2005
    Location
    QLD - Australia
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Looping over a form for multiple entries

    Hi All,

    I'm just wondering how I would go about making this part of my form.
    I want to be able to add an itinerary of my holiday, the fields in my database include:

    'day' (as in day 1, day 2)
    'destination'
    'details'

    the amount of days for each trip is undetermined, what i would like is to be able to specify on my form 'x' number of days, and then perhaps some sort of javascript action would then loop this 'x' number of that section of the form, so i had 'x' number of 'day' 'destination' and 'details' to fill in.

    I think this is similar to something a lot of sites use on upload fields, where you specify the number of uploads you want to do, then you see x number of upload fields to work with.

    Can anyone give me the gist of where to begin with this?
    Thanks.

  2. #2
    Take The Blue Pill neilmerton's Avatar
    Join Date
    Jul 2004
    Location
    Leicester, UK
    Posts
    871
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so if i understand correctly... you go to your form, enter the number of days your holiday is (via input[text] or drop-down?) and then you are shown those many 'day', 'destination' and 'details' fields?

    one other way of doing it might be to first be presented with a form containing 'day', 'destination' and 'details' and two buttons - one for 'Go to next day' and one for 'Finish'.

    the 'Go to next day' button will simply action the form by loading all the entered details (plus a day id/number) into a session and then show the same form again. you continue doing this until you've completed all your days and then click 'Finish' which will add the session to a database (this part will need further thought).

    does this help?

  3. #3
    SitePoint Zealot keira's Avatar
    Join Date
    Aug 2005
    Location
    QLD - Australia
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by neilmerton
    so if i understand correctly... you go to your form, enter the number of days your holiday is (via input[text] or drop-down?) and then you are shown those many 'day', 'destination' and 'details' fields?

    one other way of doing it might be to first be presented with a form containing 'day', 'destination' and 'details' and two buttons - one for 'Go to next day' and one for 'Finish'.

    the 'Go to next day' button will simply action the form by loading all the entered details (plus a day id/number) into a session and then show the same form again. you continue doing this until you've completed all your days and then click 'Finish' which will add the session to a database (this part will need further thought).

    does this help?
    yeah that sounds like it will work, it's probably my best option as i'm not skilled in javascript and that's how i think i've seen it done before.
    I'll give this a go. Then I can just do a query that shows all the days as links that you can click on to go back and edit your data..
    thanks heaps!!

  4. #4
    Take The Blue Pill neilmerton's Avatar
    Join Date
    Jul 2004
    Location
    Leicester, UK
    Posts
    871
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no worries


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
  •