The error given when you try it says it all: "type property can't be changed". It doesn't make any sense to change the type attribute of an input. If you need different data, you should create a new, different input, which is exactly what you are doing with the code you posted :)
On Apr 18, 4:49 am, Ivan Podgurskiy <i...@cofelab.ru> wrote: > You may use something like this > var input = $('#input_field'); > var hidden = $('<input type="text" id="'+input.attr('id')+'" > value="'+input.val()+'" class="'+input.attr('class')+'" > />').insertBefore(input); > input.remove(); > Seehttp://dev.jquery.com/ticket/1957for more information > > > > newbuntu wrote: > > > I have a hidden "old_name" input. When "new_name" is changed, I want the > > "old_name" to appear by changing the type from "hidden" to "text". It > > gives me a script error. I guess I'm not allowed to change the "type" > > attribute. > > > However, I can change "disabled" attribute without problem. > > > Can anyone throw some light on this? > > > Thx! > > <head> > > <script> > > $(document).ready(function() { > > > $("#new_name").blur(function () { > > > if (this.value != '') { > > //$('#dis_name').removeAttr('disabled'); // this works too > > old_name.value += new_name.value; > > > $('#dis_name').attr('disabled', ''); // set disable to '' > > $('#old_name').attr('type', 'text'); // set type to 'text' > > > } > > }); > > > }); > > </script> > > </head> > > > <body> > > > disabled <input id='dis_name' type='text' disabled='disabled' > > value='Dis/Enable'> <br> > > old name <input id='old_name' type='hidden' value='old '> <br> > > new name<input id='new_name' value=''> > > > </body> > > -- > View this message in > context:http://www.nabble.com/Can-you-change-the-%22type%22-attribute-of-an-%... > Sent from the jQuery General Discussion mailing list archive at Nabble.com.