Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-08-2012, 07:26 AM   PM User | #1
salmanmanekia
New Coder

 
Join Date: Nov 2012
Posts: 10
Thanks: 3
Thanked 0 Times in 0 Posts
salmanmanekia is an unknown quantity at this point
How to change values based on user inputs

Hi,

I am new to JS and web dev in general. I have a conceptual problem in which i have to design a form which have questions and answers as options. On the basis of what option the user selects (and the data is being collected) the options to the answer to the next question changes.
For example, if for the first question , the user selects 1 then for the second question user can only select 1 or 4 . Whereas if for the first question the user has choosen 2 then for the second question then user can only select 3.
Also, after the user fills the form i have to save it in a dB.

So, my question is, Is it possible to completely do this on the client side. Once again i am not at all good with either JS or PHP. If its possible then which methods can be used and how can i interact with dB. If somebody can elobrate my problem (the first paragraph) in terms of JS/PHP(if its required) then i would be very grateful to him/her.

Thanks
salmanmanekia is offline   Reply With Quote
Old 11-08-2012, 11:29 AM   PM User | #2
vwphillips
Senior Coder

 
Join Date: Mar 2005
Location: Portsmouth UK
Posts: 4,353
Thanks: 3
Thanked 457 Times in 444 Posts
vwphillips is a jewel in the roughvwphillips is a jewel in the roughvwphillips is a jewel in the rough
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
  <title></title>
<script type="text/javascript">
/*<![CDATA[*/
function Disable(obj,nme){
 var frm=obj.form,r=frm[nme],args=Disable.arguments,z0=0,z0a;
 for (z0=0;z0<r.length;z0++){
  r[z0].disabled=true;
  for (z0a=2;z0a<args.length;z0a++){
   if (args[z0a]-1==z0){
    r[z0].removeAttribute('disabled');
   }
  }
 }

}
/*]]>*/
</script></head>

<body>
<form>
<input type="radio" name="q1" onclick="Disable(this,'q2',1,4);" />
<input type="radio" name="q1" onclick="Disable(this,'q2',2);" />
<br />
<input type="radio" name="q2" disabled="disabled"/>
<input type="radio" name="q2" disabled="disabled"/>
<input type="radio" name="q2" disabled="disabled"/>
<input type="radio" name="q2" disabled="disabled"/>
</form>
</body>

</html>
__________________
Vic

God Loves You and will never love you less.

http://www.vicsjavascripts.org.uk/

If my post has been useful please donate to http://www.operationsmile.org.uk/
vwphillips is online now   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:26 PM.


Advertisement
Log in to turn off these ads.