Jump to content

How to change data on form when choosing next radio button (watch listing)?

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Stasonix

Stasonix

    Learning Programmer

  • Members
  • PipPipPip
  • 82 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal
it is a test(Questions with answers):
<!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">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>QUESTIONS</title>

<script language="javascript">

 var sr = 0;

function nextquest()

 {

 

    sr++;

        if(sr > 2) sr = 0;

        document.forms['stas'].choise[sr].checked = true;  

  

  

  

  };

 

</script>

</head>

<FORM name="stas">

<div id="myquests">

<INPUT type="radio" name="choise" checked="checked"/> 1. 

<INPUT TYPE="radio" name="choise"/> 2.

<INPUT TYPE="radio" name="choise"/> 3.

</div>

<br />

 1. Question: London is a capital of... <br />

 <INPUT type="radio" name="otv" checked="checked" /> Russian Federation <BR />

 <INPUT TYPE="radio" name="otv" /> USA <br />

 <INPUT TYPE="radio" name="otv" /> Great Britain <br />

 <INPUT TYPE="radio" name="otv" /> Australia <br/>

 <INPUT TYPE="button" name="dali" onclick="nextquest();" value="Next" />

 

</FORM>

<body>

</body>

</html>
so how to do that when pressing "Next" button a content of form will change to next Question with answers?
How you can see by pressing Next it is turns horizontal radio buttons, but it must change question to next.
Next Question for example:
2. Who is Devid Backham
1) Basketball Player
2) Football Player
3) Hockey Player
4) Singer

#2
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
That depends how you want to handle it. You could send an AJAX Request to the server with the answer for number 1, or just hide the current fields until all answers are filled out. Do another request to get the next question and update the content accordingly.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users