EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Aod47 on January 26, 2020, 05:58:01 AM



Title: How to change Easyui elements ID, Name
Post by: Aod47 on January 26, 2020, 05:58:01 AM
I tried code

Code:
$('#old_id').attr("id", 'new_id').attr("name", 'new_name');

but it does not work.

Some hidden input that  generated by Easyui don't change to new id, name.

Could you please advice.

Thank you.



Title: Re: How to change Easyui elements ID, Name
Post by: jarry on January 28, 2020, 02:03:43 AM
Please set the 'name' attribute on the form field.
Code:
<input class="easyui-textbox" name="name" style="width:100%" data-options="label:'Name:',required:true">
<input class="easyui-textbox" name="email" style="width:100%" data-options="label:'Email:',required:true,validType:'email'">


Title: Re: How to change Easyui elements ID, Name
Post by: Aod47 on January 28, 2020, 06:45:35 PM
Thank you, Sir.

I check from console and see some attribute was generate by Easyui eg. textboxname, comboname
So I was change attribute value to new_id too. It does work.

Code:
// for textboox
$('#old_id').attr('id', 'new_id').attr('name', 'new_id').attr('textboxname', 'new_id');
// and change hidden input to
$('.textbox-value[name="old_id"]').attr("name", new_id);