i have following script.
problems i want to add answers to database from admin side with iscorrect option.if type is multiple it can have multiple answers so multiple checkbox will be selected and those are are iscorrect options add as 1 to the db and those are nt checked are 0 in db.
i am not able to access checkbox array they are not getting accessed.
accessed bt prblm is that if i checked 1st and 3rd then values must be 1 0 1
bt it storing 1 1 0
2nd problem
when the select type is objective then allow user to check only one checkbox to check iam nt able to do that.
so please help me anyone as my whole project is stopped here.
echo "<BR>";
if (!isset($_SESSION[alogin]))
{
echo "<br><h2><div class=head1>You are not Logged On Please Login to Access this Page</div></h2>";
echo "<a href=index.php><h3 align=center>Click Here for Login</h3></a>";
exit();
}
echo "<BR><h3 class=head1>Add Question </h3>";
if($_POST[submit]=='Save' || strlen($_POST['testid'])>0 )
{
extract($_POST);
//query to insert data in question table
$result=mysql_query("insert into mst_question(que_id,test_id,que_desc,isMultiple) values ('','$testid','$que','$quetype')",$cn) or die(mysql_error());
$cnt=$cnt+1;
$query = "select MAX(que_id) from mst_question";
$result = mysql_query($query);
$data = mysql_fetch_array($result);
$quemax= $data[0];
var i=1;
function addans()
{
{
document.getElementById('opt1').innerHTML=document.getElementById('opt1').innerHTML+'<br><input type="checkbox" name="t[]" value="true" id="+i+" onclick="check11()"><textarea name="addans1[]" cols="60" rows="2" id="addans1" ></textarea>';
}
i++;
}
function display(obj)
{
var c = document.getElementById('adans');
document.getElementById('opt1').innerHTML = '';
if(obj.selectedIndex == 3)
{
c.style.visibility = 'hidden';
document.getElementById('opt1').innerHTML=document.getElementById('opt1').innerHTML+'<br><input type="radio" name="tr" value="true">'+'True<br><input type="radio" name="tr" value="false">False';
}
else
{
c.style.visibility='visible';
}
}
function check11()
{
var c = document.getElementsByName('quetype');
if(c.selectedIndex==2)
{
var count = 0;
var checkBoxes = document.getElementsByTagName('input');
for (var index = 0; index < checkBoxes.length; index++)
{
if (checkBoxes[index].type == 'checkbox')
{
if (!checkBoxes[index].disabled)
{
count = checkBoxes[index].checked ? (count + 1) : count;
}
}
}
if (count > 1)
{
alert('Maximum of one checkboxes only can be selected');
return false;
}
return true;
// var numbers = new Array();
////for (i = 0; i < document.form1.t.length; i++)
////{
////numbers[i] = document.form1.t[i].value;
////}
////alert("hi"+numbers[0]);
//}
Bookmarks