Your question is very confusing but I will try my best to help. I'm going to assume you want to retrieve this information via AJAX. I'll also assume your CakePHP controller spits out the following when called (you can find out by going to: http://yoursite/Forms/views):
This is some random string
In order to use this as I've presumed, you will need to do this:
<script language="javascript">
$(function() {
$(".select"+increment).change(function () {
$.get('/Forms/views',{},function(data) {
if(data == 'This is some random string') {
// I have no idea where you are getting the
// 'stringinc' and 'labelname' variables from.
$("<label id=labelstr"+stringinc+" >"+labelname+"</label>").appendTo(".menu li");
$("<input id=inputstr"+stringinc+" type= 'text' ></input>").appendTo(".menu li");
}
});
});
});
</script>
Now, if you are trying to do it the way Oliver is suggesting (except just in CakePHP), you would need to do this:
<script language="javascript">
$(function() {
$(".select"+increment).change(function () {
// I'm not familiar with Cake, you might need to use
// some sort of template syntax. Either way, whatever
// method you need to use to get the value into you view
// let's just assume its called '$value_from_controller'.
var data = <?= $value_from_controller; ?>;
if(data == 'This is some random string') {
// I have no idea where you are getting the
// 'stringinc' and 'labelname' variables from.
$("<label id=labelstr"+stringinc+" >"+labelname+"</label>").appendTo(".menu li");
$("<input id=inputstr"+stringinc+" type= 'text' ></input>").appendTo(".menu li");
}
});
});
</script>
I hope that helps in some way.