Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > CSS > CSS Cascading Style Sheets
|
CSS Cascading Style Sheets All issues relating to Cascading Style Sheets (CSS).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the CSS Cascading Style Sheets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 18th, 2006, 08:10 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default apply the 'readonly' attribute to all textboxes

Code:
<input type="text" class="font4" name="OutDispDate" value="" id="OutDispDate" readonly />
<input type="text" class="font4" name="OutDispClass" value="" id="OutDispClass" readonly />
Is there a way to apply the 'readonly' attribute to all textboxes on the page with CSS?

www.crmpicco.co.uk
www.ie7.com
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old April 18th, 2006, 09:10 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii Crmpicco!!
<script>
function call()
{
obj=document.all.length
for(i=0;i<obj;i++)
{

    if(document.all[i].type=="text")
    {
        document.all[i].readOnly=true
    }
}
}
</script>
<body >

<input type=button onclick="call()">
<input type=text name=z value=1230>
<input type=text name=z value=1230>
<input type=text name=z value=1230>
<input type=text name=z value=1230>
<input type=text name=z value=1230>
<input type=text name=z value=1230>
</body>

Plz check some browser do not support document.all ;)
Hope this will help you


Cheers :)

vinod
 
Old April 18th, 2006, 09:25 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

thanks Vinod, that was helpful. However, i was just enquiring if it was possible to do it in CSS? I.e

<style type=text/css>
Text {readonly: true}
</style>



www.crmpicco.co.uk
www.ie7.com
 
Old April 20th, 2006, 04:51 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hi Crmpicco!!
Its not possible with single syntax(in css) like you provided.

while input.readOnly/input.readonly works great,
you can't set the readonly value using single statement (by using css),you need to incorporate javascript for this ,and check the type=text on that function.

alternatively you can also use getElementsByTagName('input'); and then check type=text and make it to readOnly=true as i posted in previous post.

Hope this will help you


Cheers :)

vinod
 
Old April 20th, 2006, 06:35 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

thank you Vinod, the code you posted was great. seems it cant be done in CSS then, thank you anyway!

www.crmpicco.co.uk
www.ie7.com
 
Old April 24th, 2006, 05:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 425
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You can't even make one input readonly with CSS. That is not what CSS is for.

--
http://yupapa.com
 
Old April 24th, 2006, 07:58 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

thanks vinod and meow

www.crmpicco.co.uk
www.ie7.com
 
Old April 24th, 2006, 01:57 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

There are some things in the works for controling the presentation of these elements depending on their state, read more about that here:

http://www.w3.org/TR/2004/CR-css3-ui-20040511/

There is also another CSS 3 module in development for extending CSS to include behavioral enhancements that traditionally have their place in script and markup, such as the ability to attach JS events from CSS.

http://www.w3.org/TR/1999/WD-becss-19990804

You can do something like this now using purely script and Dean Edwards's cssQuery, which works in /every/ modern browser you'd have to worry about.

http://dean.edwards.name/my/cssQuery/

Of course it'll likely be years still before we see any of the official W3C stuff in a browser. Although Explorer can do that with CSS behaviors now, but that feature is proprietary and not implemented by other browsers at this time.

http://msdn.microsoft.com/workshop/a...s/overview.asp

Dean Edwards also wrote something to help gecko-based browsers to understand Explorer behaviors. (Ain't he just a swell guy??) :)

http://dean.edwards.name/moz-behaviors/

Personally, I'll just stick with markup and script. Regardless of which method you chose, script is going to be involved anyway.

Regards,
Rich

--
Author,
Beginning CSS: Cascading Style Sheets For Web Design
CSS Instant Results

http://www.catb.org/~esr/faqs/smart-questions.html
 
Old April 24th, 2006, 11:47 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii richard!!

Excellent link!

Thanks Again


Cheers :)

vinod
 
Old April 26th, 2006, 05:26 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

thanks Richard, the moz-behaviours link was very interesting. I did wonder if IE-only code could be modified to be cross-browser!

Danke schon!

www.crmpicco.co.uk
www.ie7.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Recordset is readonly vb.net-newbie ADO.NET 1 May 8th, 2007 11:12 AM
DataBase is readonly debabrata ASP.NET 2.0 Professional 0 April 17th, 2007 04:54 AM
Access to attribute values from class of attribute jacob C# 1 October 28th, 2005 01:11 PM
Readonly checkbox nerssi HTML Code Clinic 1 May 20th, 2005 06:28 AM
Set all textboxes to ReadOnly nobreferreira Pro VB.NET 2002/2003 6 October 15th, 2004 01:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.