subjects and the totalQuestions
when it selects the choice in the totalQuestions dropdown
it calls an onchange function makeAnswere(choice,rowId) which checks if the choice is,
1.multiple choice question
2.true/false
3.yes/no
if it is multiple choice then it creates a select element on run time by using
Expand|Select|Wrap|Line Numbers
- document.createElement()
Expand|Select|Wrap|Line Numbers
- function makeAnswere(choice,rowId){
- if(choice=="MC"){
- clrAns(rowId);
- var Inp=document.createElement("select");
- Inp.setAttribute("id","TotalChoices");
- Inp.setAttribute("name","TotalChoices");
- Inp.setAttribute("onchange","getAnsweresChoices(this.value,"+rowId+")");
- Inp.length=5;
- divEle=document.getElementById("choices_div_"+rowId);
- divEle.innerHTML="<table cellspacing='0' cellpadding='0' border='0' align='center' width='600'>"+
- "<tr><td align='left' valign='middle' width='300'>Select total Answeres</td></tr>"+
- "<tr><td align='left' valign='middle' id='choicer_"+rowId+"'></td></tr>"+
- "</table>";
- divChoice=document.getElementById("choicer_"+rowId);
- divChoice.appendChild(Inp);
- Inp.options[0].value="none";
- Inp.options[1].value=2;
- Inp.options[2].value=3;
- Inp.options[3].value=4;
- Inp.options[4].value=5;
- Inp.options[0].text="Please Select Any";
- Inp.options[1].text=2;
- Inp.options[2].text=3;
- Inp.options[3].text=4;
- Inp.options[4].text=5;
- }
- if(choice=="TF"){
- trueFalsePopulate(rowId);
- }
- if(choice=="YN"){
- clrAns(rowId);
- YesNoPopu(rowId);
- }
- if(choice=="none"){
- clrAns(rowId);
- clrChoice(rowId);
- }
- }
- function trueFalsePopulate(rowId){
- xmlPopTf=GetXmlHttpObject();
- if(xmlPopTf==null){
- alert("Please Upgrade Your Browser");
- return;
- }else{
- var url="ajax/populate-inputs.php";
- var str_tf="r_tf="+Math.random()+"&rowId="+rowId;
- xmlPopTf.onreadystatechange=$popuTrue;
- xmlPopTf.open("POST",url,true);
- xmlPopTf.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
- xmlPopTf.send(str_tf);
- }
- }
- function $popuTrue(){if(xmlPopTf.readyState==4){if(xmlPopTf.status==200){var a=xmlPopTf.responseText.split("|");clrChoice(a[1]);document.getElementById('answeres_div_'+a[1]).innerHTML=a[0];}}}
- function YesNoPopu(rowId){
- xmlPopYn=GetXmlHttpObject();
- if(xmlPopYn==null){
- alert("Please Upgrade Your Browser");
- return;
- }else{
- var url="ajax/populate-inputs.php";
- var str_yn="r_yn="+Math.random()+"&rowId="+rowId;
- xmlPopYn.onreadystatechange=$popuYn;
- xmlPopYn.open("POST",url,true);
- xmlPopYn.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
- xmlPopYn.send(str_yn);
- }
- }
- function $popuYn(){
- if(xmlPopYn.readyState==4){
- if(xmlPopYn.status==200){
- var a=xmlPopYn.responseText.split("|");
- clrChoice(a[1]);
- document.getElementById('answeres_div_'+a[1]).innerHTML=a[0];
- }
- }
- }