...

View Full Version : Help with dynamic form (javascript)



cimm.mann
05-19-2009, 11:07 AM
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//75/ContestForm.clsp?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

Philip M
05-19-2009, 12:18 PM
You should use something like the folllowing:-


<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.

cimm.mann
05-19-2009, 02:12 PM
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

cimm.mann
05-19-2009, 02:50 PM
thanks again

Philip M
05-19-2009, 04:30 PM
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.

cimm.mann
05-19-2009, 08:02 PM
http://info.campaignmaster.co.uk/rp//75/ContestForm.clsp?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!

Philip M
05-19-2009, 08:14 PM
http://info.campaignmaster.co.uk/rp//75/ContestForm.clsp?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.

cimm.mann
05-20-2009, 09:54 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum