Link to home
Start Free TrialLog in
Avatar of hidrau
hidrauFlag for Brazil

asked on

How can I set readonly for all my input that has a prefix name "f_tab_4"?

Hello guys

I have 30 inputs, 10 inputs has this prefix name

f_tab_4_??????

Is there any way to set all input with  prefix "f_tab_4_" to readonly and a attibute name upd="0" ?

<input type="text"  id="f_tab_4_frete"  upd="0" />
<input type="text"  id="f_tab_4_clie"  upd="0" />
<input type="text"  id="f_tab_4_cod"  upd="0" />
<input type="text"  id="f_tab_4_desc"  upd="0" />
<input type="text"  id="f_tab_4_prod"  upd="0" />
<input type="text"  id="f_tab_4_uf"  upd="0" />
<input type="text"  id="f_tab_4_raz"  upd="0" />

<input type="text"  id="f_tab_4_ema"  upd="1" />
<input type="text"  id="f_tab_4_was"  upd="1" />
<input type="text"  id="f_tab_4_tipo"  upd="1" />

Open in new window


thanks
Avatar of zappafan2k2
zappafan2k2

Try this:
$('[id^="f_tab_4_"]').attr('readonly','readonly').attr('upd','0');

Open in new window

Avatar of hidrau

ASKER

hello zappafan2k2

I tried and the code put readonly in all inputs and not only in inputs with upd="0".

I think I wasn't clearly with my needs.

The function must set all inputs to readonly only when the input has the tag upd="0" and not to add the tag upd="0". Did you get it?
Sorry.
$('[id^="f_tab_4_"]').find('[upd="0"]').attr('readonly','readonly');

Open in new window

Avatar of hidrau

ASKER

I tried but it didn't work :(
Avatar of hidrau

ASKER

I think the problem is with find() function. If I take off it, it worked fine but set all input readonly
ASKER CERTIFIED SOLUTION
Avatar of zappafan2k2
zappafan2k2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hidrau

ASKER

yes friend. Now it worked fine.

Thanks very much for your helo
Avatar of hidrau

ASKER

thanks