unset hidden form cakephp
how do i unset this option from a input?
im using ajax to po开发者_JS百科pulate this field and after that i need to show it
thanks
You can't reliably alter the type
of an input, but you can create a new element and copy the various attributes across:
$(document).ready(
function(){
$('<input type="text" />')
.appendTo('form')
.val($('input:hidden[name=nameOfHiddenElement]').val())
.attr('name','nameAsAppropriate')
.remove('input:hidden[name=nameOfHiddenElement]');
}
);
Link to a (basic) JS Fiddle demo
I would recommend against creating an <input type="hidden" />
, then trying to awkwardly transform it into the type you're after. Instead, create it with whatever type you need (text, select, etc.), and use CSS to hide it initially.
In your view, for example:
<style type="text/css">
input.hidden { display: none; }
</style>
<?php echo $this->Form->input('Model.fieldName', array('type'=>'text','class'=>'hidden'))?>
Then, in your AJAX callback, reveal the input:
$.ajax('/ajax/url/here', {}, function(response, status){
// perform your field population, then...
$('input.hidden').show();
});
精彩评论