i am having Cakephp code like
<?php foreach ($viewfields as $r):
if($r['Attribute']['type']=='radio')
{
?>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function($){
$("#"+<?=$r['Attribute']['id'];?>).each(function() {
type= "<?=$r['Attribute']['type'];?>";
attribute_id="<?=$r['Attribute']['id'];?>";
if(type=="radio")
{
var ht = $.ajax({
type: "GET",
url: "http://localhost/FormBuilder/index.php/forms/viewChoices/"+attribute_id,
async: false
}).responseText;
var myObject = eval('(' + ht + ')');
var data = myObject;var j=0;
$.map(data.choices, function(i){ j++;
alert(i.choice);
return i.choice;});
}//type==radio
});//each
});//jquery
</script>
<?php
echo $form->input('field', array(
'type' => 'radio','legend'=>$r['Attribute']['label'],
'separator' => '--separator--',
'options' => array()
));
}//if php type == radio
endforeach; ?>
alert(i.choice);/alerts me the choices for the label gender as male and female
and for the label "experience as yes and no..
How to place male and female in the 'options' => array() ..please suggest me...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…