1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

jquery loop help

Discussion in 'HTML & Website Design' started by youngestpr, Oct 10, 2013.

  1. #1
    I am trying to loop between rows with jquery. I have 3 html fields and i want each field to appear one after the other. This is working so far but my challenge is that after the last field appears, I expect the loop to start all over i.e the 1st field be shown again. This does not happen. Any help will be appreciated and attached is my code
     

    Attached Files:

    youngestpr, Oct 10, 2013 IP
  2. creativewebmaster

    creativewebmaster Active Member

    Messages:
    654
    Likes Received:
    7
    Best Answers:
    4
    Trophy Points:
    78
    #2
    May this help you.

    $(document).ready(function(){function playslider(){
    $('.img3').fadeIn(500).delay(500).fadeOut(500);
    $('.img4').delay(1300).fadeIn(500).delay(500).fadeOut(500);}
    playslider();});
     
    creativewebmaster, Oct 11, 2013 IP
  3. youngestpr

    youngestpr Greenhorn

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    Thanks for the prompt response but the issue i am having is about the loop and not showing or hiding the fields. the fields are showing and hiding quite well, my only issue is that after getting to the last field and user has made an input on that it should return to the first which does not happen. This is the sequence

    1.Display field 1
    2. User inputs field 1 and submits (value shows up on the right column)
    3. Display field 2
    4. User inputs field 2 and submits (value shows up on the right column)
    5. Display last field
    6. User inputs last field and submits (value shows up on the right column)
    loop starts all over
    7. Display field 1
    8. User inputs field 1 and submits (value shows up on the right column)
    9. Display field 2
    and so on...
     
    youngestpr, Oct 11, 2013 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #4
    Really my question would be why are you pissing all over a simple form with all this jquery BS? You're just making an already inaccessible non-semantic form harder to use.

    Rule #1, make the page work without scripting FIRST, especially on something important like a signup form! Just let people type **** in normally and then *SHOCK* submit it normally. Quite literally all you are doing is making it harder to use.

    ... particularly that rubbish markup with tables for layout, no LABEL, no FIELDSET, and MANY times the code that should be needed.
     
    deathshadow, Oct 11, 2013 IP
  5. youngestpr

    youngestpr Greenhorn

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #5
    I managed to get it working. I just changed the looping part to
    var i = parseInt( $(cont).attr("index") );
    i += 1;
    $("#qline" + i).show();
    $(cont).attr("index", i);
    if(i === 3) $(cont).attr("index", 0);
    and it works. Thanks for your response
     
    youngestpr, Oct 11, 2013 IP