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 8 of 8
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Help with dynamic form (javascript)

    Hi,

    I have a dynamic form which allows questions to come up according to the users answers.

    What I want to do is hide all the questions until they get to it.

    http://info.campaignmaster.co.uk/rp/...sp?FormId=1438

    So for example the question before the 'which games console do you like' I would want that question to be hidden and make a question before it that asks if they own a games console. When they click no the games console question does not show up. When they say yes the question does show up.

    I guess i want to hide all the questions by default until they answer accordingly for it and them have all the questions listed etc

    Hope you understand what i mean and i hope this help

    Cimm

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    You should use something like the folllowing:-

    Code:
    <div id = "Q1" style=display:block>Question One<br>
    Answer to Question One <input type = "text" id = txt1" onblur = "showNext('Q2')">
    </div>
    
    <div id = "Q2" style=display:none>Question Two<br>
    Answer to Question Two <input type = "text" id = txt2" onblur = "showNext('Q3')">
    </div>
    
    <div id = "Q3" style=display:none>Question Three<br>
    Answer to Question Three <input type = "text" id = txt3" onblur = "showNext('Q4')">
    </div>
    
    <div id = "Q4" style=display:none>Question Four<br>
    Answer to Question Three <input type = "text" id = txt4" onblur = "showNext('Q5')">
    </div>
    
    <div id = "Q5" style=display:none>Question Five<br>
    Answer to Question Five <input type = "text" id = txt5">
    </div>
    
    
    <script type = "text/javascript">
    
    function showNext(which) {
    document.getElementById(which).style.display="block";
    }
    </script>

    Your form appears to have no validation of the various input fields.


    "He has been in the final of the tournament before, and people often go on from there to win it ...." Snooker commentator.

  • #3
    New Coder
    Join Date
    May 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post another help

    This works good but could you please help me

    i want the next answer to appear when the answer is selected - currently i have to click off the answer
    also i would like it if you click off the answer given - the next question will disapear

    thanks
    Last edited by cimm.mann; 05-19-2009 at 02:09 PM.

  • #4
    New Coder
    Join Date
    May 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post another help!!!

    thanks again
    Last edited by cimm.mann; 05-19-2009 at 02:09 PM.

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    There is a difference between pointing you in the right direction, and doing all the work for you.
    Show us how far you have got with these changes.

    You have admitted that this is homework. Sorry, but will not do your work for you.
    Last edited by Philip M; 05-19-2009 at 03:35 PM.

  • #6
    New Coder
    Join Date
    May 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    this is how far ive got

    http://info.campaignmaster.co.uk/rp/...sp?FormId=1443

    i was joking lol... its not my homework... its just something i need to do for work but i cant figure it out!

  • #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by cimm.mann View Post
    http://info.campaignmaster.co.uk/rp/...sp?FormId=1443

    i was joking lol... its not my homework... its just something i need to do for work but i cant figure it out!
    I believe you. Others wouldn't.

    There is a delicate balance between asking for help with a specific Javascript problem, and getting others to do your paid work or your uni homework for you. You are over the dividing line. You cannot go through life expecting others to do your work for you.

  • #8
    New Coder
    Join Date
    May 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Fair enough

    Hi,

    I know nothing about javascript and thought I could get help here. Sorry to bother you. I will ask someone else.

    Thanks for the first part you gave me it did help alot


  •  

    Posting Permissions

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