Hi, I am using JQuery where i am trying to use the Cakephp Controller returned values in the JQuery input element..
I have two variables returned from my CakePHP controller action $entries and $attributes.. $attributes will return the Fieldname and its type,size $entries will return the Fieldname and the value submitted for the Field.
Both are array variables Here i have created the Corresponding Input element using
<?php foreach ($attributes as $r): ?>
$("<div id= <?php echo $r['Attribute']['label'];?> ></div>").appendTo("#main");
$("<input id=input<?php echo $r['Attribute']['id'];?> type= 'text' style= 'width:<?php echo $r['Attribute']['size'];?>px'value='<?php echo $attribute['Result']['value'];?>' ?> ></input><br>").appendTo("#main");
$("<div id= <?php echo $r['Attribute']['type'];?> ></div>").appendTo("#main");
<?php endforeach; ?>
In the above code where i am creating the Input element it shows me the correct Input element based on it.But within that input element when i tried to use like value='' ?>
i have to keep the
<?php endforeach;?>
where inside this only i can use the
How to do so.. Please suggest me.. SInce both are for loops i dont know how to use them since when i keep it will be creating as much number of times..
<script type="text/javascript">
$(document).ready(function(){
$(".edi").click(function (){
<?php foreach ($attributes as $r): ?>
$("<div id= <?php echo $r['Attribute']['label'];?> ></div>").appendTo("#main");
$("<input id=input<?php echo $r['Attribute']['id'];?> type= 'text' style= 'width:<?php echo $r['Attribute']['size'];?>px'value='<?php echo $attribute['Result']['value'];?>' ?> ></input><br>").appendTo("#main");
$("<div id= <?php echo $r['Attribute']['type'];?> ></div>").appendTo("#main");
<?php endforeach; ?>
$(".edi").hide();$(".vie").show();
return false;
});
});
</script>
EDIT: I have kept for retriving the fields(type,size,fieldname) from the Attributes table.. is for retriving the That fields entries (label,value)...
On clicking the Edit button ,,, i am generating the input elements with sizes where i got it from $r['Attribute']['size'] as
$(" type= 'text' style= 'width:px'value='' ?> >
").appendTo("#main");
This shows me the correct generation of input elements with correct sizes of what it retrieves from the table..
Now inside this i.e. in the Input elements i want to show the value of this corresponding field of what i m retriving from using $r1['Result']['value']; THis is where i am not able to make this values to show inside the Input Elements..Please help me......