how do i unset this option from a input?
im using ajax to populate this field and after that i need to show it
thanks
how do i unset this option from a input?
im using ajax to populate 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]');
}
);
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();
});