Avatar of hidrau
hidrau
Flag 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
jQuery

Avatar of undefined
Last Comment
hidrau

8/22/2022 - Mon
zappafan2k2

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

Open in new window

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?
zappafan2k2

Sorry.
$('[id^="f_tab_4_"]').find('[upd="0"]').attr('readonly','readonly');

Open in new window

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
hidrau

ASKER
I tried but it didn't work :(
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
zappafan2k2

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
hidrau

ASKER
yes friend. Now it worked fine.

Thanks very much for your helo
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
hidrau

ASKER
thanks