codeigniter form_radio()
---- I have solved the radio button problem. now the problem is i need to send the value $thing->quistionNo in the controller along with the answer.---
&开发者_StackOverflow中文版lt;?php echo form_open(base_url() . 'things/show');
foreach ($data->result()as $thing) {
echo $thing->questionNo.". ".$thing->question;
$qno =array(
'name' => 'qno',
'id' => 'qno',
'value' => $thing->questionNo
);
//$qno = $thing->questionNo;
var_dump($qno);
?>
<ul>
<li>
<div>
<?php echo form_radio("answer", "1", (set_value("answer") == "1"));
echo $thing->option1; ?>
</div>
</li>
<li>
<div>
<?php echo form_radio("answer", "2", (set_value("answer") == "2"));
echo $thing->option2; ?>
</div>
</li>
<li>
<div>
<?php echo form_radio("answer", "3", (set_value("answer") == "3"));
echo $thing->option3; ?>
</div>
</li>
<li>
<div>
<?php echo form_radio("answer", "4", (set_value("answer") == "4"));
echo $thing->option4; ?>
</div>
</li>
<?php }
echo form_submit(array('name' => 'submit'), 'Submit Answer');
echo form_close();
?>
</body>
</html>
There's a problem with your form_submit.
form_submit has 2 parameters, which accept name and value of the input.
echo form_submit('oksubmit', 'Submit!');
which will produce:
<input type="submit" name="oksubmit" value="Submit!" />
For more information you can refer to here
精彩评论