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
jQuery

Avatar of undefined
Last Comment
hidrau
Avatar of zappafan2k2
zappafan2k2

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

Open in new window

Avatar of hidrau
hidrau
Flag of Brazil image

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

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

Open in new window

Avatar of hidrau
hidrau
Flag of Brazil image

ASKER

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

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of hidrau
hidrau
Flag of Brazil image

ASKER

yes friend. Now it worked fine.

Thanks very much for your helo
Avatar of hidrau
hidrau
Flag of Brazil image

ASKER

thanks
jQuery
jQuery

jQuery (Core) is a cross-browser JavaScript library that provides abstractions for common client-side tasks such as Document Object Model (DOM) traversal, DOM manipulation, event handling, animation and Ajax. jQuery also provides a platform to create plugins that extend jQuery's capabilities beyond those already provided by the library.

19K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo