Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > CSS > CSS Cascading Style Sheets
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 18th, 2006, 08:10 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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
Reply With Quote
  #2 (permalink)  
Old April 18th, 2006, 09:10 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
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
Reply With Quote
  #3 (permalink)  
Old April 18th, 2006, 09:25 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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
Reply With Quote
  #4 (permalink)  
Old April 20th, 2006, 04:51 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
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
Reply With Quote
  #5 (permalink)  
Old April 20th, 2006, 06:35 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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
Reply With Quote
  #6 (permalink)  
Old April 24th, 2006, 05:54 AM
Friend of Wrox
Points: 1,315, Level: 14
Points: 1,315, Level: 14 Points: 1,315, Level: 14 Points: 1,315, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , .
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
Reply With Quote
  #7 (permalink)  
Old April 24th, 2006, 07:58 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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
Reply With Quote
  #8 (permalink)  
Old April 24th, 2006, 01:57 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
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
Reply With Quote
  #9 (permalink)  
Old April 24th, 2006, 11:47 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
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
Reply With Quote
  #10 (permalink)  
Old April 26th, 2006, 05:26 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:49 PM.


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